PR#107
This commit is contained in:
parent
f74716922d
commit
158381dfbb
|
@ -20,7 +20,7 @@ describe("errors", () => {
|
|||
// All those errors propagete up and are returned by the resolver
|
||||
test("unknown function", () =>
|
||||
expect(MathJs.Eval.eval("testZadanga()"))->toEqual(
|
||||
Error(ErrorValue.REJs(Some("Undefined function testZadanga"), Some("Error"))),
|
||||
Error(ErrorValue.REJavaScriptExn(Some("Undefined function testZadanga"), Some("Error"))),
|
||||
)
|
||||
)
|
||||
|
||||
|
|
|
@ -67,6 +67,6 @@ let dispatch = (call: functionCall): result<expressionValue, errorValue> =>
|
|||
// So we have to recreate a copy of the string
|
||||
ExternalLibrary.dispatch((Js.String.make(fn), args), callInternal)
|
||||
} catch {
|
||||
| Js.Exn.Error(obj) => REJs(Js.Exn.message(obj), Js.Exn.name(obj))->Error
|
||||
| Js.Exn.Error(obj) => REJavaScriptExn(Js.Exn.message(obj), Js.Exn.name(obj))->Error
|
||||
| _ => RETodo("unhandled rescript exception")->Error
|
||||
}
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
type errorValue =
|
||||
| REArrayIndexNotFound(string, int)
|
||||
| REFunctionExpected(string)
|
||||
| REJs(option<string>, option<string>) // Javascript Exception
|
||||
| REJavaScriptExn(option<string>, option<string>) // Javascript Exception
|
||||
| RERecordPropertyNotFound(string, string)
|
||||
| RETodo(string) // To do
|
||||
|
||||
|
@ -9,7 +9,7 @@ let showError = err =>
|
|||
switch err {
|
||||
| REArrayIndexNotFound(msg, index) => `${msg}: ${Js.String.make(index)}`
|
||||
| REFunctionExpected(msg) => `Function expected: ${msg}`
|
||||
| REJs(omsg, oname) => {
|
||||
| REJavaScriptExn(omsg, oname) => {
|
||||
let answer = "JS Exception:"
|
||||
let answer = switch oname {
|
||||
| Some(name) => `${answer} ${name}`
|
||||
|
|
|
@ -22,6 +22,6 @@ let eval = (expr: string): result<expressionValue, errorValue> => {
|
|||
let answer = eval__(expr)
|
||||
answer["value"]->JavaScript.Gate.jsToEv
|
||||
} catch {
|
||||
| Js.Exn.Error(obj) => REJs(Js.Exn.message(obj), Js.Exn.name(obj))->Error
|
||||
| Js.Exn.Error(obj) => REJavaScriptExn(Js.Exn.message(obj), Js.Exn.name(obj))->Error
|
||||
}
|
||||
}
|
||||
|
|
|
@ -44,7 +44,7 @@ let parse = (expr: string): result<node, errorValue> =>
|
|||
try {
|
||||
Ok(parse__(expr))
|
||||
} catch {
|
||||
| Js.Exn.Error(obj) => REJs(Js.Exn.message(obj), Js.Exn.name(obj))->Error
|
||||
| Js.Exn.Error(obj) => REJavaScriptExn(Js.Exn.message(obj), Js.Exn.name(obj))->Error
|
||||
}
|
||||
|
||||
type mathJsNode =
|
||||
|
|
Loading…
Reference in New Issue
Block a user