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

Side by Side Diff: luci_config/server/cfgclient/backend/authority.go

Issue 2963503003: [errors] Greatly simplify common/errors package. (Closed)
Patch Set: fix nits Created 3 years, 5 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
1 // Copyright 2016 The LUCI Authors. All rights reserved. 1 // Copyright 2016 The LUCI Authors. All rights reserved.
2 // Use of this source code is governed under the Apache License, Version 2.0 2 // Use of this source code is governed under the Apache License, Version 2.0
3 // that can be found in the LICENSE file. 3 // that can be found in the LICENSE file.
4 4
5 package backend 5 package backend
6 6
7 import ( 7 import (
8 "bytes" 8 "bytes"
9 9
10 "github.com/luci/luci-go/common/errors" 10 "github.com/luci/luci-go/common/errors"
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
45 // We use a shorthand notation so that we don't waste space in JSON. 45 // We use a shorthand notation so that we don't waste space in JSON.
46 func (a Authority) MarshalJSON() ([]byte, error) { 46 func (a Authority) MarshalJSON() ([]byte, error) {
47 switch a { 47 switch a {
48 case AsAnonymous: 48 case AsAnonymous:
49 return asAnonymousJSON, nil 49 return asAnonymousJSON, nil
50 case AsService: 50 case AsService:
51 return asServiceJSON, nil 51 return asServiceJSON, nil
52 case AsUser: 52 case AsUser:
53 return asUserJSON, nil 53 return asUserJSON, nil
54 default: 54 default:
55 » » return nil, errors.Reason("unknown authority: %(auth)v").D("auth ", a).Err() 55 » » return nil, errors.Reason("unknown authority: %v", a).Err()
56 } 56 }
57 } 57 }
58 58
59 // UnmarshalJSON implements encoding/json.Unmarshaler. 59 // UnmarshalJSON implements encoding/json.Unmarshaler.
60 func (a *Authority) UnmarshalJSON(d []byte) error { 60 func (a *Authority) UnmarshalJSON(d []byte) error {
61 switch { 61 switch {
62 case bytes.Equal(d, asAnonymousJSON): 62 case bytes.Equal(d, asAnonymousJSON):
63 *a = AsAnonymous 63 *a = AsAnonymous
64 case bytes.Equal(d, asServiceJSON): 64 case bytes.Equal(d, asServiceJSON):
65 *a = AsService 65 *a = AsService
66 case bytes.Equal(d, asUserJSON): 66 case bytes.Equal(d, asUserJSON):
67 *a = AsUser 67 *a = AsUser
68 default: 68 default:
69 » » return errors.Reason("unknown authority JSON value: %(auth)v").D ("auth", d).Err() 69 » » return errors.Reason("unknown authority JSON value: %v", d).Err( )
70 } 70 }
71 return nil 71 return nil
72 } 72 }
OLDNEW
« no previous file with comments | « luci_config/server/cfgclient/access/access.go ('k') | luci_config/server/cfgclient/backend/caching/codec.go » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698