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