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

27 lines
808 B
Plaintext
Raw Normal View History

2022-03-29 09:09:59 +00:00
type errorValue =
| REArrayIndexNotFound(string, int)
| REFunctionExpected(string)
2022-03-30 09:06:30 +00:00
| REJavaScriptExn(option<string>, option<string>) // Javascript Exception
2022-03-29 09:09:59 +00:00
| 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}`
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
}
| RERecordPropertyNotFound(msg, index) => `${msg}: ${index}`
| RETodo(msg) => `TODO: ${msg}`
}