templates = t
}
+func internalServerError(ctx context.Context, w http.ResponseWriter, err error) {
+ log.Errorf(ctx, "%v", err)
+
+ http.Error(w, "Internal Server Error\n\nReference: "+appengine.RequestID(ctx), http.StatusInternalServerError)
+}
+
// ContextHandler implements http.Handler
type ContextHandler func(context.Context, http.ResponseWriter, *http.Request) error
ctx := appengine.NewContext(r)
if err := app.LoadConfig(ctx); err != nil {
- http.Error(w, err.Error(), http.StatusInternalServerError)
+ internalServerError(ctx, w, fmt.Errorf("LoadConfig() = %v", err))
return
}
if err := hndl(ctx, w, r); err != nil {
- http.Error(w, err.Error(), http.StatusInternalServerError)
+ internalServerError(ctx, w, err)
return
}
}
ctx := appengine.NewContext(r)
if err := app.LoadConfig(ctx); err != nil {
- http.Error(w, err.Error(), http.StatusInternalServerError)
+ internalServerError(ctx, w, fmt.Errorf("LoadConfig() = %v", err))
return
}
if gaeUser == nil {
url, err := user.LoginURL(ctx, r.URL.String())
if err != nil {
- http.Error(w, err.Error(), http.StatusInternalServerError)
+ internalServerError(ctx, w, fmt.Errorf("LoginURL() = %v", err))
return
}
http.Redirect(w, r, url, http.StatusTemporaryRedirect)
u, err := app.NewUser(ctx, gaeUser.Email)
if err != nil {
- http.Error(w, err.Error(), http.StatusInternalServerError)
+ internalServerError(ctx, w, fmt.Errorf("NewUser(%q) = %v", gaeUser.Email, err))
return
}
if err := hndl(ctx, w, r, u); err != nil {
- http.Error(w, err.Error(), http.StatusInternalServerError)
+ internalServerError(ctx, w, err)
return
}
}