2022-04-11 03:16:31 +00:00
|
|
|
@genType
|
2022-03-29 09:09:59 +00:00
|
|
|
type errorValue =
|
|
|
|
| REArrayIndexNotFound(string, int)
|
2022-04-08 12:14:37 +00:00
|
|
|
| REAssignmentExpected
|
|
|
|
| REExpressionExpected
|
2022-03-29 09:09:59 +00:00
|
|
|
| REFunctionExpected(string)
|
2022-03-30 09:06:30 +00:00
|
|
|
| REJavaScriptExn(option<string>, option<string>) // Javascript Exception
|
2022-04-08 12:14:37 +00:00
|
|
|
| REMacroNotFound(string)
|
2022-03-29 09:09:59 +00:00
|
|
|
| RERecordPropertyNotFound(string, string)
|
2022-04-08 12:14:37 +00:00
|
|
|
| RESymbolNotFound(string)
|
2022-04-05 20:02:06 +00:00
|
|
|
| RESyntaxError(string)
|
2022-03-29 09:09:59 +00:00
|
|
|
| RETodo(string) // To do
|
|
|
|
|
2022-03-30 09:45:30 +00:00
|
|
|
type t = errorValue
|
|
|
|
|
2022-04-11 06:16:29 +00:00
|
|
|
@genType
|
2022-03-30 10:53:36 +00:00
|
|
|
let errorToString = err =>
|
2022-03-29 09:09:59 +00:00
|
|
|
switch err {
|
|
|
|
| REArrayIndexNotFound(msg, index) => `${msg}: ${Js.String.make(index)}`
|
2022-04-08 12:14:37 +00:00
|
|
|
| REAssignmentExpected => "Assignment expected"
|
|
|
|
| REExpressionExpected => "Expression expected"
|
2022-03-29 09:09:59 +00:00
|
|
|
| REFunctionExpected(msg) => `Function expected: ${msg}`
|
2022-03-30 09:06:30 +00:00
|
|
|
| REJavaScriptExn(omsg, oname) => {
|
2022-03-29 09:09:59 +00:00
|
|
|
let answer = "JS Exception:"
|
|
|
|
let answer = switch oname {
|
|
|
|
| Some(name) => `${answer} ${name}`
|
|
|
|
| _ => answer
|
|
|
|
}
|
|
|
|
let answer = switch omsg {
|
|
|
|
| Some(msg) => `${answer}: ${msg}`
|
|
|
|
| _ => answer
|
|
|
|
}
|
|
|
|
answer
|
|
|
|
}
|
2022-04-08 12:14:37 +00:00
|
|
|
| REMacroNotFound(macro) => `Macro not found: ${macro}`
|
2022-03-29 09:09:59 +00:00
|
|
|
| RERecordPropertyNotFound(msg, index) => `${msg}: ${index}`
|
2022-04-08 12:14:37 +00:00
|
|
|
| RESymbolNotFound(symbolName) => `${symbolName} is not defined`
|
2022-04-05 20:02:06 +00:00
|
|
|
| RESyntaxError(desc) => `Syntax Error: ${desc}`
|
2022-03-29 09:09:59 +00:00
|
|
|
| RETodo(msg) => `TODO: ${msg}`
|
|
|
|
}
|