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

Unified Diff: logdog/common/types/streamaddr.go

Issue 2963503003: [errors] Greatly simplify common/errors package. (Closed)
Patch Set: fix nits Created 3 years, 6 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « logdog/common/storage/entry.go ('k') | logdog/server/archivist/archivist.go » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: logdog/common/types/streamaddr.go
diff --git a/logdog/common/types/streamaddr.go b/logdog/common/types/streamaddr.go
index 2dca9dcf9168b77f3d30b60559d5f7b4cb1973d3..afe4a5e8abc0bc88e10aee55ff2a52ea7236feda 100644
--- a/logdog/common/types/streamaddr.go
+++ b/logdog/common/types/streamaddr.go
@@ -78,14 +78,12 @@ func (s *StreamAddr) URL() *url.URL {
func ParseURL(v string) (*StreamAddr, error) {
u, err := url.Parse(v)
if err != nil {
- return nil, errors.Annotate(err).Reason("failed to parse URL").Err()
+ return nil, errors.Annotate(err, "failed to parse URL").Err()
}
// Validate Scheme.
if u.Scheme != logDogURLScheme {
- return nil, errors.Reason("URL scheme %(scheme)q is not "+logDogURLScheme).
- D("scheme", u.Scheme).
- Err()
+ return nil, errors.Reason("URL scheme %q is not %s", u.Scheme, logDogURLScheme).Err()
}
addr := StreamAddr{
Host: u.Host,
@@ -93,22 +91,16 @@ func ParseURL(v string) (*StreamAddr, error) {
parts := strings.SplitN(u.Path, "/", 3)
if len(parts) != 3 || len(parts[0]) != 0 {
- return nil, errors.Reason("URL path does not include both project and path components: %(path)s").
- D("path", u.Path).
- Err()
+ return nil, errors.Reason("URL path does not include both project and path components: %s", u.Path).Err()
}
addr.Project, addr.Path = cfgtypes.ProjectName(parts[1]), StreamPath(parts[2])
if err := addr.Project.Validate(); err != nil {
- return nil, errors.Annotate(err).Reason("invalid project name: %(project)q").
- D("project", addr.Project).
- Err()
+ return nil, errors.Annotate(err, "invalid project name: %q", addr.Project).Err()
}
if err := addr.Path.Validate(); err != nil {
- return nil, errors.Annotate(err).Reason("invalid stream path: %(path)q").
- D("path", addr.Path).
- Err()
+ return nil, errors.Annotate(err, "invalid stream path: %q", addr.Path).Err()
}
return &addr, nil
« no previous file with comments | « logdog/common/storage/entry.go ('k') | logdog/server/archivist/archivist.go » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698