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

Side by Side Diff: deploytool/cmd/luci_deploy/param.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
« no previous file with comments | « deploytool/cmd/luci_deploy/manage.go ('k') | deploytool/cmd/luci_deploy/path.go » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 main 5 package main
6 6
7 import ( 7 import (
8 "regexp" 8 "regexp"
9 "strings" 9 "strings"
10 10
(...skipping 22 matching lines...) Expand all
33 // v[m[2]:m[3]] is the paramter key (first capture group) 33 // v[m[2]:m[3]] is the paramter key (first capture group)
34 parts = append(parts, v[sidx:m[0]]) 34 parts = append(parts, v[sidx:m[0]])
35 sidx = m[1] 35 sidx = m[1]
36 36
37 key := v[m[2]:m[3]] 37 key := v[m[2]:m[3]]
38 if val, ok := subs[key]; ok { 38 if val, ok := subs[key]; ok {
39 parts = append(parts, val) 39 parts = append(parts, val)
40 } else { 40 } else {
41 // panic to immediately stop matching. This will be caug ht at the top of 41 // panic to immediately stop matching. This will be caug ht at the top of
42 // this function. 42 // this function.
43 » » » return errors.Reason("undefined parameter %(key)q").D("k ey", key).Err() 43 » » » return errors.Reason("undefined parameter %q", key).Err( )
44 } 44 }
45 } 45 }
46 46
47 // Finish the string and return. 47 // Finish the string and return.
48 parts = append(parts, v[sidx:]) 48 parts = append(parts, v[sidx:])
49 *vp = strings.Join(parts, "") 49 *vp = strings.Join(parts, "")
50 return nil 50 return nil
51 } 51 }
OLDNEW
« no previous file with comments | « deploytool/cmd/luci_deploy/manage.go ('k') | deploytool/cmd/luci_deploy/path.go » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698