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

Side by Side Diff: client/isolate/utils.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 | « cipd/client/cipd/ensure/template.go ('k') | common/config/impl/filesystem/fs.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 2015 The LUCI Authors. All rights reserved. 1 // Copyright 2015 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 isolate 5 package isolate
6 6
7 import ( 7 import (
8 "fmt"
9 "log" 8 "log"
10 "path" 9 "path"
11 "runtime" 10 "runtime"
12 "strings" 11 "strings"
13 12
14 "github.com/luci/luci-go/common/errors" 13 "github.com/luci/luci-go/common/errors"
15 ) 14 )
16 15
17 // TODO(tandrii): Remove this hacky stuff. 16 // TODO(tandrii): Remove this hacky stuff.
18 // hacky stuff for faster debugging. 17 // hacky stuff for faster debugging.
19 func assertNoError(err error) { 18 func assertNoError(err error) {
20 if err == nil { 19 if err == nil {
21 return 20 return
22 } 21 }
23 » log.Panic(errors.RenderStack(fmt.Errorf("assertion failed due to error: %s", err)).ToLines()) 22 » log.Panic(errors.RenderStack(errors.Annotate(err, "assertion failed").Er r()))
24 } 23 }
25 24
26 func assert(condition bool, info ...interface{}) { 25 func assert(condition bool, info ...interface{}) {
27 if condition { 26 if condition {
28 return 27 return
29 } 28 }
30 if len(info) == 0 { 29 if len(info) == 0 {
31 » » log.Panic(errors.RenderStack(errors.New("assertion failed")).ToL ines()) 30 » » log.Panic(errors.RenderStack(errors.New("assertion failed")))
32 } else if format, ok := info[0].(string); ok { 31 } else if format, ok := info[0].(string); ok {
33 » » log.Panic(errors.RenderStack(fmt.Errorf("assertion failed: "+for mat, info[1:]...)).ToLines()) 32 » » log.Panic(errors.RenderStack(errors.Reason("assertion failed: "+ format, info[1:]...).Err()))
34 } 33 }
35 } 34 }
36 35
37 // uniqueMergeSortedStrings merges two sorted sets of string (as slices) and rem oves duplicates. 36 // uniqueMergeSortedStrings merges two sorted sets of string (as slices) and rem oves duplicates.
38 func uniqueMergeSortedStrings(ls, rs []string) []string { 37 func uniqueMergeSortedStrings(ls, rs []string) []string {
39 varSet := make([]string, len(ls)+len(rs)) 38 varSet := make([]string, len(ls)+len(rs))
40 for i := 0; ; i++ { 39 for i := 0; ; i++ {
41 if len(ls) == 0 { 40 if len(ls) == 0 {
42 rs, ls = ls, rs 41 rs, ls = ls, rs
43 } 42 }
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after
132 } 131 }
133 return string(buf), nil 132 return string(buf), nil
134 } 133 }
135 return targ[t0:], nil 134 return targ[t0:], nil
136 } 135 }
137 136
138 // IsWindows returns True when running on the best OS there is. 137 // IsWindows returns True when running on the best OS there is.
139 func IsWindows() bool { 138 func IsWindows() bool {
140 return runtime.GOOS == "windows" 139 return runtime.GOOS == "windows"
141 } 140 }
OLDNEW
« no previous file with comments | « cipd/client/cipd/ensure/template.go ('k') | common/config/impl/filesystem/fs.go » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698