Add 'SetNode' support to IError interface

This commit is contained in:
Sameer Rahmani 2020-12-12 20:28:32 +00:00
parent aa1079c6b6
commit 572899318f
1 changed files with 10 additions and 1 deletions

View File

@ -29,6 +29,7 @@ type IError interface {
IPrintable
IDebuggable
WithError(err error) IError
SetNode(n *Node)
}
type Error struct {
@ -54,16 +55,24 @@ func (e *Error) WithError(err error) IError {
return e
}
func (e *Error) SetNode(n *Node) {
e.Node = *n
}
func (e *Error) Error() string {
return e.msg
}
func MakeError(rt *Runtime, msg string) IError {
func MakePlainError(msg string) IError {
return &Error{
msg: msg,
}
}
func MakeError(rt *Runtime, msg string) IError {
return MakePlainError(msg)
}
func MakeErrorFor(rt *Runtime, e IExpr, msg string) IError {
loc := e.GetLocation()