messages.js (3618B)
1 import { distErrorToString } from "../dist/DistError.js"; 2 export class ErrorMessage extends Error { 3 } 4 export class REArityError extends ErrorMessage { 5 constructor(fn, arity, usedArity) { 6 super(); 7 this.fn = fn; 8 this.arity = arity; 9 this.usedArity = usedArity; 10 } 11 toString() { 12 return `${this.arity} arguments expected. Instead ${this.usedArity} argument(s) were passed.`; 13 } 14 } 15 export class REArrayIndexNotFound extends ErrorMessage { 16 constructor(msg, index) { 17 super(); 18 this.msg = msg; 19 this.index = index; 20 } 21 toString() { 22 return `${this.msg}: ${this.index}`; 23 } 24 } 25 export class REDistributionError extends ErrorMessage { 26 constructor(err) { 27 super(); 28 this.err = err; 29 } 30 toString() { 31 return `Distribution Math Error: ${distErrorToString(this.err)}`; 32 } 33 } 34 export class REExpectedType extends ErrorMessage { 35 constructor(typeName, valueString) { 36 super(); 37 this.typeName = typeName; 38 this.valueString = valueString; 39 } 40 toString() { 41 return `Expected type: ${this.typeName} but got: ${this.valueString}`; 42 } 43 } 44 export class RENotAFunction extends ErrorMessage { 45 constructor(value) { 46 super(); 47 this.value = value; 48 } 49 toString() { 50 return `${this.value} is not a function`; 51 } 52 } 53 export class REOperationError extends ErrorMessage { 54 constructor(err) { 55 super(); 56 this.err = err; 57 } 58 toString() { 59 return `Math Error: ${this.err.toString()}`; 60 } 61 } 62 export class REDictPropertyNotFound extends ErrorMessage { 63 constructor(msg, index) { 64 super(); 65 this.msg = msg; 66 this.index = index; 67 } 68 toString() { 69 return `${this.msg}: ${this.index}`; 70 } 71 } 72 export class RESymbolNotFound extends ErrorMessage { 73 constructor(symbolName) { 74 super(); 75 this.symbolName = symbolName; 76 } 77 toString() { 78 return `${this.symbolName} is not defined`; 79 } 80 } 81 export class RESyntaxError extends ErrorMessage { 82 constructor(desc) { 83 super(); 84 this.desc = desc; 85 } 86 toString() { 87 return `Syntax Error: ${this.desc}`; 88 } 89 } 90 export class RETodo extends ErrorMessage { 91 constructor(msg) { 92 super(); 93 this.msg = msg; 94 } 95 toString() { 96 return `TODO: ${this.msg}`; 97 } 98 } 99 export class REDomainError extends ErrorMessage { 100 constructor(value, domain) { 101 super(); 102 this.value = value; 103 this.domain = domain; 104 } 105 toString() { 106 return `Domain Error: Parameter ${this.value} must be in domain ${this.domain}`; 107 } 108 } 109 export class REJavaScriptExn extends ErrorMessage { 110 constructor(msg, name) { 111 super(); 112 this.msg = msg; 113 this.name = name; 114 } 115 toString() { 116 let answer = `JS Exception: ${this.name}`; 117 if (this.msg.length) 118 answer += `: ${this.msg}`; 119 return answer; 120 } 121 } 122 export class REArgumentError extends ErrorMessage { 123 constructor(msg) { 124 super(msg); 125 this.msg = msg; 126 } 127 toString() { 128 return `Argument Error: ${this.message}`; 129 } 130 } 131 export class REOther extends ErrorMessage { 132 constructor(msg) { 133 super(msg); 134 this.msg = msg; 135 } 136 toString() { 137 return `Error: ${this.message}`; 138 } 139 } 140 export class REAmbiguous extends ErrorMessage { 141 constructor(msg) { 142 super(msg); 143 this.msg = msg; 144 } 145 toString() { 146 return `Ambiguous Error: ${this.message}`; 147 } 148 } 149 //# sourceMappingURL=messages.js.map