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

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

Issue 1637193002: common/prpc, tools/cmd/cproto: prpc client (Closed) Base URL: https://github.com/luci/luci-go@prpc-server
Patch Set: Add Context-derived timeout for Client. 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
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 {
iannucci 2016/01/27 02:55:49 Wrapped?
dnj (Google) 2016/01/27 03:24:25 Agreed, done.
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

Powered by Google App Engine
This is Rietveld 408576698