Skip to content

Commit 10f1000

Browse files
committed
#354 500 error for token creation fail
1 parent 5d2124a commit 10f1000

1 file changed

Lines changed: 12 additions & 0 deletions

File tree

pkg/responses/responses.go

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,18 @@ func Error403(w http.ResponseWriter, r *http.Request, e error) {
114114
renderError(w, "403 Forbidden")
115115
}
116116

117+
// Error500 Internal Error
118+
// something is not right, hopefully this never happens
119+
func Error500(w http.ResponseWriter, r *http.Request, e error) {
120+
log.Error(e)
121+
log.Infof("If this error persists it may be worthy of a bug report but please check your setup first. See the README at %s", cfg.Branding.URL)
122+
addErrandCancelRequest(r)
123+
cookie.ClearCookie(w, r)
124+
w.Header().Set(cfg.Cfg.Headers.Error, e.Error())
125+
w.WriteHeader(http.StatusInternalServerError)
126+
renderError(w, "500 - Internal Server Error")
127+
}
128+
117129
// cfg.ErrCtx is tested by `jwtmanager.JWTCacheHandler`
118130
func addErrandCancelRequest(r *http.Request) {
119131
ctx, cancel := context.WithCancel(r.Context())

0 commit comments

Comments
 (0)