Example #1
0
File: vm.go Project: postfix/anko
// NewError makes error interface with message. This doesn't overwrite last error.
func NewError(pos ast.Pos, err error) error {
	if err == nil {
		return nil
	}
	if err == BreakError || err == ContinueError || err == ReturnError {
		return err
	}
	if pe, ok := err.(*parser.Error); ok {
		return pe
	}
	if ee, ok := err.(*Error); ok {
		return ee
	}
	return &Error{Message: err.Error(), Pos: pos.Position()}
}
Example #2
0
File: vm.go Project: postfix/anko
// NewStringError makes error interface with message.
func NewErrorf(pos ast.Pos, format string, args ...interface{}) error {
	return &Error{Message: fmt.Sprintf(format, args...), Pos: pos.Position()}
}
Example #3
0
File: vm.go Project: postfix/anko
// NewStringError makes error interface with message.
func NewStringError(pos ast.Pos, err string) error {
	return &Error{Message: err, Pos: pos.Position()}
}