Exemple #1
0
// 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()}
}
Exemple #2
0
// 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()}
}
Exemple #3
0
// NewStringError makes error interface with message.
func NewStringError(pos ast.Pos, err string) error {
	return &Error{Message: err, Pos: pos.Position()}
}