1
0
mirror of https://github.com/MontFerret/ferret.git synced 2025-11-06 08:39:09 +02:00

Added panic recovery mechanism (#158)

This commit is contained in:
Tim Voronov
2018-11-05 11:45:33 -05:00
committed by GitHub
parent 4032e8dd7c
commit 5e6701f1c1
3 changed files with 46 additions and 4 deletions

View File

@@ -59,9 +59,6 @@ func (c *FqlCompiler) Compile(query string) (program *runtime.Program, err error
return nil, ErrEmptyQuery
}
p := parser.New(query)
p.AddErrorListener(&errorListener{})
defer func() {
if r := recover(); r != nil {
// find out exactly what the error was and set err
@@ -78,6 +75,9 @@ func (c *FqlCompiler) Compile(query string) (program *runtime.Program, err error
}
}()
p := parser.New(query)
p.AddErrorListener(&errorListener{})
l := newVisitor(query, c.funcs)
res := p.Visit(l).(*result)