Skip to content

Commit

Permalink
oauth2: scopes should be separated by %20 and not +, to ensure javasc…
Browse files Browse the repository at this point in the history
…ript compatibility (#278)

* herodot: improve error logging
* oauth2: scopes should be separated by %20 and not +, to ensure javascript compatibility - closes #277
  • Loading branch information
arekkas authored Oct 3, 2016
1 parent 16209f6 commit e33df89
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 8 deletions.
10 changes: 5 additions & 5 deletions glide.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 3 additions & 1 deletion herodot/error.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,9 @@ func ToError(err error) *Error {

func LogError(err error, id string, code int) {
logrus.WithError(err).WithField("request_id", id).WithField("status", code).Errorln("An error occurred")
if e, ok := errors.Cause(err).(stackTracer); ok {
if e, ok := err.(stackTracer); ok {
logrus.Debugf("Stack trace: %+v", e.StackTrace())
} else if e, ok := errors.Cause(err).(stackTracer); ok {
logrus.Debugf("Stack trace: %+v", e.StackTrace())
} else if e, ok := err.(*Error); ok {
LogError(e.OriginalError, id, code)
Expand Down
4 changes: 2 additions & 2 deletions herodot/json.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ func (h *JSON) WriteCode(ctx context.Context, w http.ResponseWriter, r *http.Req

func (h *JSON) WriteError(ctx context.Context, w http.ResponseWriter, r *http.Request, err error) {
e := ToError(err)
h.WriteErrorCode(ctx, w, r, e.StatusCode, e)
h.WriteErrorCode(ctx, w, r, e.StatusCode, err)
return
}

Expand All @@ -59,9 +59,9 @@ func (h *JSON) WriteErrorCode(ctx context.Context, w http.ResponseWriter, r *htt
code = http.StatusInternalServerError
}

LogError(err, id, code)
je := ToError(err)
je.StatusCode = code
LogError(je, id, code)
h.WriteCode(ctx, w, r, je.StatusCode, &jsonError{
RequestID: id,
Error: ToError(err),
Expand Down

0 comments on commit e33df89

Please sign in to comment.