xgo/compiler/parser/error.go
earncef 6dd573c3f6 Runtime error trace format (#111)
* Runtime error format

* Parser and Compiler error formats updated
2019-02-22 13:39:07 -08:00

21 lines
359 B
Go

package parser
import (
"fmt"
"github.com/d5/tengo/compiler/source"
)
// Error represents a parser error.
type Error struct {
Pos source.FilePos
Msg string
}
func (e Error) Error() string {
if e.Pos.Filename != "" || e.Pos.IsValid() {
return fmt.Sprintf("Parse Error: %s\n\tat %s", e.Msg, e.Pos)
}
return fmt.Sprintf("Parse Error: %s", e.Msg)
}