mirror of
https://github.com/go-sylixos/elvish.git
synced 2024-12-12 17:27:50 +08:00
pkg/eval: Remove the bool return value of GetCompilationError.
This is done for consistency with parse.GetError.
This commit is contained in:
parent
7584319b69
commit
5f0e4fc196
|
@ -10,11 +10,11 @@ func NewCompilationError(message string, context diag.Context) error {
|
|||
Type: compilationErrorType, Message: message, Context: context}
|
||||
}
|
||||
|
||||
// GetCompilationError returns a *diag.Error and true if the given value is a
|
||||
// compilation error. Otherwise it returns nil and false.
|
||||
func GetCompilationError(e interface{}) (*diag.Error, bool) {
|
||||
// GetCompilationError returns a *diag.Error if the given value is a compilation
|
||||
// error. Otherwise it returns nil.
|
||||
func GetCompilationError(e interface{}) *diag.Error {
|
||||
if e, ok := e.(*diag.Error); ok && e.Type == compilationErrorType {
|
||||
return e, true
|
||||
return e
|
||||
}
|
||||
return nil, false
|
||||
return nil
|
||||
}
|
||||
|
|
|
@ -54,7 +54,7 @@ func compile(b, g *staticNs, tree parse.Tree, w io.Writer) (op Op, err error) {
|
|||
r := recover()
|
||||
if r == nil {
|
||||
return
|
||||
} else if e, ok := GetCompilationError(r); ok {
|
||||
} else if e := GetCompilationError(r); e != nil {
|
||||
// Save the compilation error and stop the panic.
|
||||
err = e
|
||||
} else {
|
||||
|
|
Loading…
Reference in New Issue
Block a user