projects
/
kraftakt.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Always print an error when reporting an "internal server error" to the user.
[kraftakt.git]
/
kraftakt.go
diff --git
a/kraftakt.go
b/kraftakt.go
index
61a576e
..
4c69459
100644
(file)
--- a/
kraftakt.go
+++ b/
kraftakt.go
@@
-43,6
+43,12
@@
func init() {
templates = t
}
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
// ContextHandler implements http.Handler
type ContextHandler func(context.Context, http.ResponseWriter, *http.Request) error
@@
-50,12
+56,12
@@
func (hndl ContextHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
ctx := appengine.NewContext(r)
if err := app.LoadConfig(ctx); err != nil {
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 {
return
}
if err := hndl(ctx, w, r); err != nil {
-
http.Error(w, err.Error(), http.StatusInternalServerErro
r)
+
internalServerError(ctx, w, er
r)
return
}
}
return
}
}
@@
-66,7
+72,7
@@
func (hndl AuthenticatedHandler) ServeHTTP(w http.ResponseWriter, r *http.Reques
ctx := appengine.NewContext(r)
if err := app.LoadConfig(ctx); err != nil {
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
}
return
}
@@
-74,7
+80,7
@@
func (hndl AuthenticatedHandler) ServeHTTP(w http.ResponseWriter, r *http.Reques
if gaeUser == nil {
url, err := user.LoginURL(ctx, r.URL.String())
if err != nil {
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)
return
}
http.Redirect(w, r, url, http.StatusTemporaryRedirect)
@@
-83,12
+89,12
@@
func (hndl AuthenticatedHandler) ServeHTTP(w http.ResponseWriter, r *http.Reques
u, err := app.NewUser(ctx, gaeUser.Email)
if err != nil {
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 {
return
}
if err := hndl(ctx, w, r, u); err != nil {
-
http.Error(w, err.Error(), http.StatusInternalServerErro
r)
+
internalServerError(ctx, w, er
r)
return
}
}
return
}
}