Skip to content

Commit

Permalink
Use errors.As
Browse files Browse the repository at this point in the history
  • Loading branch information
antonmedv committed Dec 26, 2023
1 parent c87f8f2 commit 280d28d
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion expr.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package expr

import (
"errors"
"fmt"
"reflect"

Expand Down Expand Up @@ -199,7 +200,8 @@ func Compile(input string, ops ...Option) (*vm.Program, error) {
if config.Optimize {
err = optimizer.Optimize(&tree.Node, config)
if err != nil {
if fileError, ok := err.(*file.Error); ok {
var fileError *file.Error
if errors.As(err, &fileError) {
return nil, fileError.Bind(tree.Source)
}
return nil, err
Expand Down

0 comments on commit 280d28d

Please sign in to comment.