Skip to content

Commit ce2a54e

Browse files
committed
Add error
1 parent cfcf737 commit ce2a54e

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

error.go

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
package expr
2+
3+
import (
4+
"fmt"
5+
"strings"
6+
)
7+
8+
type syntaxError struct {
9+
message string
10+
input string
11+
pos int
12+
}
13+
14+
func (e *syntaxError) Error() string {
15+
snippet := ""
16+
if len(e.input) > 0 {
17+
snippet = fmt.Sprintf("\n%s\n%s", e.input, strings.Repeat("-", e.pos)+"^")
18+
}
19+
return e.message + snippet
20+
}

0 commit comments

Comments
 (0)