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

Side by Side Diff: luci_config/server/cfgclient/backend/get_all.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 18 matching lines...) Expand all
29 ) 29 )
30 30
31 // MarshalJSON implements json.Marshaler. 31 // MarshalJSON implements json.Marshaler.
32 func (gat GetAllTarget) MarshalJSON() ([]byte, error) { 32 func (gat GetAllTarget) MarshalJSON() ([]byte, error) {
33 switch gat { 33 switch gat {
34 case GetAllProject: 34 case GetAllProject:
35 return projectJSON, nil 35 return projectJSON, nil
36 case GetAllRef: 36 case GetAllRef:
37 return refJSON, nil 37 return refJSON, nil
38 default: 38 default:
39 » » return nil, errors.Reason("unknown GetAllTarget: %(value)v").D(" value", gat).Err() 39 » » return nil, errors.Reason("unknown GetAllTarget: %v", gat).Err()
40 } 40 }
41 } 41 }
42 42
43 // UnmarshalJSON implements json.Unmarshaler. 43 // UnmarshalJSON implements json.Unmarshaler.
44 func (gat *GetAllTarget) UnmarshalJSON(d []byte) error { 44 func (gat *GetAllTarget) UnmarshalJSON(d []byte) error {
45 switch { 45 switch {
46 case bytes.Equal(d, projectJSON): 46 case bytes.Equal(d, projectJSON):
47 *gat = GetAllProject 47 *gat = GetAllProject
48 case bytes.Equal(d, refJSON): 48 case bytes.Equal(d, refJSON):
49 *gat = GetAllRef 49 *gat = GetAllRef
50 default: 50 default:
51 » » return errors.Reason("unknown GetAllTarget: %(value)q").D("value ", d).Err() 51 » » return errors.Reason("unknown GetAllTarget: %q", d).Err()
52 } 52 }
53 return nil 53 return nil
54 } 54 }
OLDNEW
« no previous file with comments | « luci_config/server/cfgclient/backend/format/formatters.go ('k') | luci_config/server/cfgclient/resolver.go » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698