-
-
Notifications
You must be signed in to change notification settings - Fork 452
Closed
Description
I find that my own error information of method and function turned to string, and I can't use it conveniently. The go 1.20 has the new function 'errors.Join' and I think the expr code about recover can modify like this
func (vm *VM) Run(program *Program, env interface{}) (_ interface{}, err error) {
defer func() {
if r := recover(); r != nil {
f := &file.Error{
Location: program.Locations[vm.ip-1],
}
var ok bool
if err, ok = r.(error); !ok {
f.Message = fmt.Sprintf("%v", r)
err = f.Bind(program.Source)
} else {
err = errors.Join(err, f.Bind(program.Source))
}
}
}()
//...
}
How about up to 1.20 and use the new feature ?
GeraldXv
Metadata
Metadata
Assignees
Labels
No labels