mirror of
https://github.com/smallnest/rpcx.git
synced 2025-09-26 20:21:14 +08:00
add method to return MultiError or nil
This commit is contained in:
@@ -941,10 +941,7 @@ check:
|
||||
}
|
||||
timeout.Stop()
|
||||
|
||||
if err.Error() == "[]" {
|
||||
return nil
|
||||
}
|
||||
return err
|
||||
return err.ErrorOrNil()
|
||||
}
|
||||
|
||||
// Fork sends requests to all servers and Success once one server returns OK.
|
||||
@@ -1040,11 +1037,7 @@ check:
|
||||
}
|
||||
timeout.Stop()
|
||||
|
||||
if err.Error() == "[]" {
|
||||
return nil
|
||||
}
|
||||
|
||||
return err
|
||||
return err.ErrorOrNil()
|
||||
}
|
||||
|
||||
// Inform sends requests to all servers and returns all results from services.
|
||||
@@ -1154,10 +1147,7 @@ check:
|
||||
}
|
||||
timeout.Stop()
|
||||
|
||||
if err.Error() == "[]" {
|
||||
return receipts, nil
|
||||
}
|
||||
return receipts, err
|
||||
return receipts, err.ErrorOrNil()
|
||||
}
|
||||
|
||||
// SendFile sends a local file to the server.
|
||||
|
@@ -22,6 +22,13 @@ func (e *MultiError) Append(err error) {
|
||||
e.Errors = append(e.Errors, err)
|
||||
}
|
||||
|
||||
func (e *MultiError) ErrorOrNil() error {
|
||||
if e == nil || len(e.Errors) == 0 {
|
||||
return nil
|
||||
}
|
||||
return e
|
||||
}
|
||||
|
||||
// NewMultiError creates and returns an Error with error splice
|
||||
func NewMultiError(errors []error) *MultiError {
|
||||
return &MultiError{Errors: errors}
|
||||
|
Reference in New Issue
Block a user