...
1 package expr
2
3 import (
4 `fmt`
5 )
6
7
8 type SyntaxError struct {
9 Pos int
10 Reason string
11 }
12
13 func newSyntaxError(pos int, reason string) *SyntaxError {
14 return &SyntaxError {
15 Pos : pos,
16 Reason : reason,
17 }
18 }
19
20 func (self *SyntaxError) Error() string {
21 return fmt.Sprintf("Syntax error at position %d: %s", self.Pos, self.Reason)
22 }
23
24
25 type RuntimeError struct {
26 Reason string
27 }
28
29 func newRuntimeError(reason string) *RuntimeError {
30 return &RuntimeError {
31 Reason: reason,
32 }
33 }
34
35 func (self *RuntimeError) Error() string {
36 return "Runtime error: " + self.Reason
37 }
38
View as plain text