mirror of
https://github.com/go-sylixos/elvish.git
synced 2024-12-13 01:47:51 +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}
|
Type: compilationErrorType, Message: message, Context: context}
|
||||||
}
|
}
|
||||||
|
|
||||||
// GetCompilationError returns a *diag.Error and true if the given value is a
|
// GetCompilationError returns a *diag.Error if the given value is a compilation
|
||||||
// compilation error. Otherwise it returns nil and false.
|
// error. Otherwise it returns nil.
|
||||||
func GetCompilationError(e interface{}) (*diag.Error, bool) {
|
func GetCompilationError(e interface{}) *diag.Error {
|
||||||
if e, ok := e.(*diag.Error); ok && e.Type == compilationErrorType {
|
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()
|
r := recover()
|
||||||
if r == nil {
|
if r == nil {
|
||||||
return
|
return
|
||||||
} else if e, ok := GetCompilationError(r); ok {
|
} else if e := GetCompilationError(r); e != nil {
|
||||||
// Save the compilation error and stop the panic.
|
// Save the compilation error and stop the panic.
|
||||||
err = e
|
err = e
|
||||||
} else {
|
} else {
|
||||||
|
|
Loading…
Reference in New Issue
Block a user