Make parser send error upwards instead of panicing
This commit is contained in:
parent
402644d219
commit
6b90cc488e
5 changed files with 246 additions and 129 deletions
10
wasm/wasm.go
10
wasm/wasm.go
|
|
@ -39,14 +39,14 @@ func run(this js.Value, args []js.Value) interface{} {
|
|||
|
||||
parser := core.NewParser(tokens)
|
||||
|
||||
tree := parser.Parse()
|
||||
tree, err := parser.Parse()
|
||||
|
||||
if err != nil {
|
||||
return jsErrorOfString(err.Error())
|
||||
}
|
||||
|
||||
log.Printf("Parsed tree: %s", tree.String())
|
||||
|
||||
if len(parser.Errors) > 0 {
|
||||
return jsErrorOfString(parser.Errors[0].Description)
|
||||
}
|
||||
|
||||
compiler := core.NewCompiler()
|
||||
|
||||
compiler.Compile(tree)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue