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

Side by Side Diff: server/auth/openid/method.go

Issue 2951393002: [errors] de-specialize Transient in favor of Tags. (Closed)
Patch Set: more refactor 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 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 openid 5 package openid
6 6
7 import ( 7 import (
8 "fmt" 8 "fmt"
9 "net/http" 9 "net/http"
10 "net/url" 10 "net/url"
11 "path" 11 "path"
12 "strings" 12 "strings"
13 "time" 13 "time"
14 14
15 "golang.org/x/net/context" 15 "golang.org/x/net/context"
16 16
17 "github.com/luci/luci-go/common/clock" 17 "github.com/luci/luci-go/common/clock"
18 "github.com/luci/luci-go/common/errors" 18 "github.com/luci/luci-go/common/errors"
19 "github.com/luci/luci-go/common/logging" 19 "github.com/luci/luci-go/common/logging"
20 "github.com/luci/luci-go/common/retry/transient"
20 "github.com/luci/luci-go/server/auth" 21 "github.com/luci/luci-go/server/auth"
21 "github.com/luci/luci-go/server/router" 22 "github.com/luci/luci-go/server/router"
22 ) 23 )
23 24
24 // These are installed into a HTTP router by AuthMethod.InstallHandlers(...). 25 // These are installed into a HTTP router by AuthMethod.InstallHandlers(...).
25 const ( 26 const (
26 loginURL = "/auth/openid/login" 27 loginURL = "/auth/openid/login"
27 logoutURL = "/auth/openid/logout" 28 logoutURL = "/auth/openid/logout"
28 callbackURL = "/auth/openid/callback" 29 callbackURL = "/auth/openid/callback"
29 ) 30 )
(...skipping 327 matching lines...) Expand 10 before | Expand all | Expand 10 after
357 cpy.MaxAge = -1 358 cpy.MaxAge = -1
358 cpy.Expires = time.Unix(1, 0) 359 cpy.Expires = time.Unix(1, 0)
359 http.SetCookie(rw, &cpy) 360 http.SetCookie(rw, &cpy)
360 } 361 }
361 } 362 }
362 363
363 // replyError logs the error and replies with HTTP 500 (on transient errors) or 364 // replyError logs the error and replies with HTTP 500 (on transient errors) or
364 // HTTP 400 on fatal errors (that can happen only on bad requests). 365 // HTTP 400 on fatal errors (that can happen only on bad requests).
365 func replyError(c context.Context, rw http.ResponseWriter, err error, msg string , args ...interface{}) { 366 func replyError(c context.Context, rw http.ResponseWriter, err error, msg string , args ...interface{}) {
366 code := http.StatusBadRequest 367 code := http.StatusBadRequest
367 » if errors.IsTransient(err) { 368 » if transient.Tag.In(err) {
368 code = http.StatusInternalServerError 369 code = http.StatusInternalServerError
369 } 370 }
370 msg = fmt.Sprintf(msg, args...) 371 msg = fmt.Sprintf(msg, args...)
371 logging.Errorf(c, "HTTP %d: %s", code, msg) 372 logging.Errorf(c, "HTTP %d: %s", code, msg)
372 http.Error(rw, msg, code) 373 http.Error(rw, msg, code)
373 } 374 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698