Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(677)

Unified Diff: milo/frontend/view_error.go

Issue 2977863002: [milo] Refactor all html knowledge out of backends. (Closed)
Patch Set: now with case insensitivity Created 3 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « milo/frontend/view_console.go ('k') | milo/frontend/view_frontpage.go » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: milo/frontend/view_error.go
diff --git a/milo/frontend/view_error.go b/milo/frontend/view_error.go
new file mode 100644
index 0000000000000000000000000000000000000000..57afe71379b8d597132a36284d2fbb2a658f91c9
--- /dev/null
+++ b/milo/frontend/view_error.go
@@ -0,0 +1,31 @@
+// Copyright 2017 The LUCI Authors. All rights reserved.
+// Use of this source code is governed under the Apache License, Version 2.0
+// that can be found in the LICENSE file.
+
+package frontend
+
+import (
+ "github.com/luci/luci-go/common/errors"
+ "github.com/luci/luci-go/server/router"
+ "github.com/luci/luci-go/server/templates"
+
+ "github.com/luci/luci-go/milo/common"
+)
+
+// ErrorHandler renders an error page for the user.
+func ErrorHandler(c *router.Context, err error) {
+ // TODO(iannucci): tag/extract other information from error, like a link to the
+ // 'container'; i.e. a build may link to its builder, a builder to its
+ // master/bucket, etc.
+
+ code := common.ErrorTag.In(err)
+ if code == common.CodeUnknown {
+ errors.Log(c.Context, err)
+ }
+ status := code.HTTPStatus()
+ c.Writer.WriteHeader(status)
+ templates.MustRender(c.Context, c.Writer, "pages/error.html", templates.Args{
+ "Code": status,
+ "Message": err.Error(),
+ })
+}
« no previous file with comments | « milo/frontend/view_console.go ('k') | milo/frontend/view_frontpage.go » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698