mirror of
https://github.com/go-sylixos/elvish.git
synced 2024-12-13 01:47:51 +08:00
Implement multi-error.
This commit is contained in:
parent
a41182a48a
commit
d8702d78c5
|
@ -40,6 +40,7 @@ func init() {
|
|||
&BuiltinFn{"typeof", typeof},
|
||||
|
||||
&BuiltinFn{"fail", wrapFn(fail)},
|
||||
&BuiltinFn{"multi-error", wrapFn(multiErrorFn)},
|
||||
&BuiltinFn{"return", wrapFn(returnFn)},
|
||||
&BuiltinFn{"break", wrapFn(breakFn)},
|
||||
&BuiltinFn{"continue", wrapFn(continueFn)},
|
||||
|
@ -191,6 +192,10 @@ func fail(ec *evalCtx, arg Value) {
|
|||
throw(errors.New(ToString(arg)))
|
||||
}
|
||||
|
||||
func multiErrorFn(ec *evalCtx, args ...Error) {
|
||||
throw(multiError{args})
|
||||
}
|
||||
|
||||
func returnFn(ec *evalCtx) {
|
||||
throw(Return)
|
||||
}
|
||||
|
|
|
@ -179,7 +179,7 @@ type multiError struct {
|
|||
|
||||
func (me multiError) Repr() string {
|
||||
b := new(bytes.Buffer)
|
||||
b.WriteString("(multi-error")
|
||||
b.WriteString("?(multi-error")
|
||||
for _, e := range me.errors {
|
||||
b.WriteString(" ")
|
||||
b.WriteString(e.Repr())
|
||||
|
|
Loading…
Reference in New Issue
Block a user