diff --git a/glide.lock b/glide.lock index f8c98206b87..614d03509f0 100644 --- a/glide.lock +++ b/glide.lock @@ -1,5 +1,5 @@ hash: f1931945f77f6461c6134be605c3def735f6c1e7fbabe54993f731591fa02d98 -updated: 2016-09-22T19:17:38.506625+02:00 +updated: 2016-10-03T11:23:49.9431729+02:00 imports: - name: github.com/asaskevich/govalidator version: 7664702784775e51966f0885f5cd27435916517b @@ -8,7 +8,7 @@ imports: - name: github.com/cenk/backoff version: cdf48bbc1eb78d1349cbda326a4a037f7ba565c6 - name: github.com/davecgh/go-spew - version: 5215b55f46b2b919f50a1df0eaa5886afe4e3b3d + version: 6d212800a42e8ab5c146b8ace3490ee17e5225f9 subpackages: - spew - name: github.com/dgrijalva/jwt-go @@ -60,7 +60,7 @@ imports: - pkg - rand/sequence - name: github.com/ory-am/fosite - version: aa1b8548678e5807399d35b5bcad4f62a83cf6e4 + version: e61a25f3e3d3f067141c3f6464ab4213f4e14d45 subpackages: - compose - fosite-example/pkg @@ -83,7 +83,7 @@ imports: - name: github.com/pkg/sftp version: a71e8f580e3b622ebff585309160b1cc549ef4d2 - name: github.com/pmezard/go-difflib - version: 792786c7400a136282c1664665ae0a8db921c6c2 + version: d8ed2627bdf02c080bf22230dbb337003b7aba2d subpackages: - difflib - name: github.com/Sirupsen/logrus @@ -108,7 +108,7 @@ imports: subpackages: - json - name: github.com/stretchr/testify - version: f390dcf405f7b83c997eac1b06768bb9f44dec18 + version: 69483b4bd14f5845b5a1e55bca19e954e827f1d0 subpackages: - assert - require diff --git a/herodot/error.go b/herodot/error.go index 9e475729cf7..7d8e8167b82 100644 --- a/herodot/error.go +++ b/herodot/error.go @@ -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) diff --git a/herodot/json.go b/herodot/json.go index 5bf04b3c3c7..c1d83fe172f 100644 --- a/herodot/json.go +++ b/herodot/json.go @@ -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 } @@ -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),