Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(179)

Unified Diff: common/errors/multierror.go

Issue 2958433002: [errors] Remove Fix(), move MultiErrorFromErrors(). (Closed)
Patch Set: keep it secret, keep it safe Created 3 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « common/errors/annotate_example_test.go ('k') | common/errors/multierror_test.go » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: common/errors/multierror.go
diff --git a/common/errors/multierror.go b/common/errors/multierror.go
index 23423e9dfaafc3e073fae8a947555cd794b0267d..810a705b9ce7e86d51a855676307c6f8778004e2 100644
--- a/common/errors/multierror.go
+++ b/common/errors/multierror.go
@@ -6,11 +6,6 @@ package errors
import (
"fmt"
- "reflect"
-)
-
-var (
- multiErrorType = reflect.TypeOf(MultiError(nil))
)
// MultiError is a simple `error` implementation which represents multiple
@@ -87,38 +82,3 @@ func SingleError(err error) error {
}
return err
}
-
-// MultiErrorFromErrors takes an error-channel, blocks on it, and returns
-// a MultiError for any errors pushed to it over the channel, or nil if
-// all the errors were nil.
-func MultiErrorFromErrors(ch <-chan error) error {
- if ch == nil {
- return nil
- }
- ret := MultiError(nil)
- for e := range ch {
- if e == nil {
- continue
- }
- ret = append(ret, e)
- }
- if len(ret) == 0 {
- return nil
- }
- return ret
-}
-
-// Fix will convert a MultiError compatible type (e.g. []error) to this
-// version of MultiError.
-func Fix(err error) error {
- if err != nil {
- // we know that err already conforms to the error interface (or the caller's
- // method wouldn't compile), so check to see if the error's underlying type
- // looks like one of the special error types we implement.
- v := reflect.ValueOf(err)
- if v.Type().ConvertibleTo(multiErrorType) {
- err = v.Convert(multiErrorType).Interface().(error)
- }
- }
- return err
-}
« no previous file with comments | « common/errors/annotate_example_test.go ('k') | common/errors/multierror_test.go » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698