mirror of
https://github.com/robertkrimen/otto
synced 2025-10-12 20:27:30 +08:00
Fix (band-aid) Go/JavaScript cross-boundary error transformation
This commit is contained in:
parent
d0132833fb
commit
260b2a48bf
|
@ -10,7 +10,7 @@ func Test_262(t *testing.T) {
|
|||
|
||||
test := runTest()
|
||||
test(`raise:
|
||||
42 = 42;
|
||||
eval("42 = 42;");
|
||||
`, "ReferenceError: Invalid left-hand side in assignment")
|
||||
}
|
||||
|
||||
|
|
|
@ -17,8 +17,12 @@ func builtinGlobal_eval(call FunctionCall) Value {
|
|||
}
|
||||
program, err := parse(toString(source))
|
||||
if err != nil {
|
||||
//panic(call.runtime.newError("SyntaxError", UndefinedValue()))
|
||||
panic(&_syntaxError{Message: fmt.Sprintf("%v", err)})
|
||||
switch err := err.(type) {
|
||||
case *_syntaxError, *_error, _error:
|
||||
panic(err)
|
||||
default:
|
||||
panic(&_syntaxError{Message: fmt.Sprintf("%v", err)})
|
||||
}
|
||||
}
|
||||
runtime := call.runtime
|
||||
if call.evalHint {
|
||||
|
|
|
@ -209,7 +209,7 @@ func Test_eval(t *testing.T) {
|
|||
`, "true")
|
||||
// TODO Make this a sane result
|
||||
// Lightning bolt, lightning bolt, lightning bolt, ...
|
||||
test(`ghi`, "SyntaxError: SyntaxError: SyntaxError: Unexpected token ILLEGAL ()")
|
||||
test(`ghi`, "SyntaxError: Unexpected token ILLEGAL ()")
|
||||
|
||||
test(`
|
||||
function abc(){
|
||||
|
|
|
@ -208,7 +208,7 @@ func (self *_runtime) tryEvaluate(inner func() Value) (tryValue Value, throw boo
|
|||
return
|
||||
case *_syntaxError:
|
||||
throw = true
|
||||
throwValue = toValue(self.newError("SyntaxError", toValue(caught.String())))
|
||||
throwValue = toValue(self.newError("SyntaxError", toValue(caught.Message)))
|
||||
return
|
||||
}
|
||||
panic(caught)
|
||||
|
|
Loading…
Reference in New Issue
Block a user