mirror of
https://github.com/zeromicro/go-zero.git
synced 2026-05-10 16:30:01 +08:00
refactor(core/errorx): use errors.Join simplify error handle (#4289)
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
package errorx
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"errors"
|
||||
"sync"
|
||||
)
|
||||
|
||||
@@ -52,14 +52,10 @@ func (be *BatchError) NotNil() bool {
|
||||
|
||||
// Error returns a string that represents inside errors.
|
||||
func (ea errorArray) Error() string {
|
||||
var buf bytes.Buffer
|
||||
|
||||
for i := range ea {
|
||||
if i > 0 {
|
||||
buf.WriteByte('\n')
|
||||
}
|
||||
buf.WriteString(ea[i].Error())
|
||||
}
|
||||
|
||||
return buf.String()
|
||||
return errors.Join(ea...).Error()
|
||||
}
|
||||
|
||||
// Unwrap combine the errors in the errorArray into a single error return
|
||||
func (ea errorArray) Unwrap() error {
|
||||
return errors.Join(ea...)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user