squiggle/packages/squiggle-lang/src/rescript/Reducer/Reducer_ErrorValue.res

27 lines
786 B
Plaintext
Raw Normal View History

2022-03-29 09:09:59 +00:00
type errorValue =
| REArrayIndexNotFound(string, int)
| REFunctionExpected(string)
| REJs(option<string>, option<string>) // Javascript Exception
| RERecordPropertyNotFound(string, string)
| RETodo(string) // To do
let showError = err =>
switch err {
| REArrayIndexNotFound(msg, index) => `${msg}: ${Js.String.make(index)}`
| REFunctionExpected(msg) => `Function expected: ${msg}`
| REJs(omsg, oname) => {
let answer = "JS Exception:"
let answer = switch oname {
| Some(name) => `${answer} ${name}`
| _ => answer
}
let answer = switch omsg {
| Some(msg) => `${answer}: ${msg}`
| _ => answer
}
answer
}
| RERecordPropertyNotFound(msg, index) => `${msg}: ${index}`
| RETodo(msg) => `TODO: ${msg}`
}