DistError.js (2582B)
1 import { XYShapeError } from "../XYShape.js"; 2 export const tooFewSamplesForConversionToPointSet = () => { 3 return { 4 type: "TooFewSamplesForConversionToPointSet", 5 }; 6 }; 7 export const distOperationError = (operationError) => { 8 return { 9 type: "OperationError", 10 value: operationError, 11 }; 12 }; 13 export const notYetImplemented = () => ({ 14 type: "NotYetImplemented", 15 }); 16 export const unreachableError = () => ({ 17 type: "Unreachable", 18 }); 19 export const distributionVerticalShiftIsInvalid = () => ({ 20 type: "DistributionVerticalShiftIsInvalid", 21 }); 22 export const operationDistError = (e) => ({ 23 type: "OperationError", 24 value: e, 25 }); 26 export const sparklineError = (e) => ({ 27 type: "SparklineError", 28 message: e, 29 }); 30 export const logarithmOfDistributionError = (e) => ({ 31 type: "LogarithmOfDistributionError", 32 message: e, 33 }); 34 export const requestedStrategyInvalidError = (e) => ({ 35 type: "RequestedStrategyInvalidError", 36 message: e, 37 }); 38 export const otherError = (e) => ({ 39 type: "OtherError", 40 message: e, 41 }); 42 export const argumentError = (e) => ({ 43 type: "ArgumentError", 44 message: e, 45 }); 46 export const xyShapeDistError = (e) => ({ 47 type: "XYShapeError", 48 value: e, 49 }); 50 export const distErrorToString = (e) => { 51 switch (e.type) { 52 case "NotYetImplemented": 53 return "Function not yet implemented"; 54 case "Unreachable": 55 return "Unreachable"; 56 case "DistributionVerticalShiftIsInvalid": 57 return "Distribution vertical shift is invalid"; 58 case "ArgumentError": 59 return `Argument Error ${e.message}`; 60 case "LogarithmOfDistributionError": 61 return `Logarithm of input error: ${e.message}`; 62 case "NonNumericInput": 63 return `Found a non-number in input: ${e.message}`; 64 case "OperationError": 65 return e.value.toString(); 66 case "TooFewSamplesForConversionToPointSet": 67 return "Too Few Samples to convert to point set"; 68 case "SparklineError": 69 return e.message; 70 case "RequestedStrategyInvalidError": 71 return `Requested strategy invalid: ${e.message}`; 72 case "XYShapeError": 73 return `XY Shape Error: ${XYShapeError.toString(e.value)}`; 74 case "OtherError": 75 return e.message; 76 case "TooFewSamples": 77 return "Too few samples when constructing sample set"; 78 default: 79 return `Unknown error ${JSON.stringify(e)}`; 80 } 81 }; 82 //# sourceMappingURL=DistError.js.map