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

Side by Side Diff: common/errors/wrap.go

Issue 1605363002: common/prpc, tools/cmd/cproto: prpc client (Closed) Base URL: https://chromium.googlesource.com/external/github.com/luci/luci-go@master
Patch Set: rebased and addressed comments Created 4 years, 10 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
« no previous file with comments | « common/errors/transient.go ('k') | common/logging/fields.go » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright 2016 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 // Wrap wraps an error.
8 type Wrap interface {
9 // InnerError returns the wrapped error.
10 InnerError() error
11 }
12
13 // Unwrap returns the inner error of err.
14 // Returns nil if err does not wrap anything or err is nil.
15 func Unwrap(err error) error {
16 if wrap, ok := err.(Wrap); ok {
17 return wrap.InnerError()
18 }
19 return nil
20 }
21
22 // UnwrapAll unwraps a wrapped error recursively.
23 // Returns nil iff err is nil.
24 func UnwrapAll(err error) error {
25 for {
26 inner := Unwrap(err)
27 if inner == nil {
28 break
29 }
30 err = inner
31 }
32 return err
33 }
OLDNEW
« no previous file with comments | « common/errors/transient.go ('k') | common/logging/fields.go » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698