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

Side by Side Diff: go/src/infra/libs/errors/multierror.go

Issue 1153883002: go: infra/libs/* now live in luci-go. (Closed) Base URL: https://chromium.googlesource.com/infra/infra.git@master
Patch Set: move the rest too Created 5 years, 7 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 unified diff | Download patch
OLDNEW
(Empty)
1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 package errors
6
7 import (
8 "fmt"
9 )
10
11 // MultiError is a simple `error` implementation which represents multiple
12 // `error` objects in one.
13 type MultiError []error
14
15 // MultiErrorFromErrors takes an error-channel, blocks on it, and returns
16 // a MultiError for any errors pushed to it over the channel, or nil if
17 // all the errors were nil.
18 func MultiErrorFromErrors(ch <-chan error) error {
19 if ch == nil {
20 return nil
21 }
22 ret := MultiError(nil)
23 for e := range ch {
24 if e == nil {
25 continue
26 }
27 ret = append(ret, e)
28 }
29 if len(ret) == 0 {
30 return nil
31 }
32 return ret
33 }
34
35 func (m MultiError) Error() string {
36 return fmt.Sprintf("%+q", []error(m))
37 }
OLDNEW
« no previous file with comments | « go/src/infra/libs/errors/errors_test.go ('k') | go/src/infra/libs/funnybase/binary_vals_test.go » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698