OLD | NEW |
(Empty) | |
| 1 // Copyright 2017 The LUCI Authors. All rights reserved. |
| 2 // Use of this source code is governed under the Apache License, Version 2.0 |
| 3 // that can be found in the LICENSE file. |
| 4 |
| 5 package frontend |
| 6 |
| 7 import ( |
| 8 "github.com/luci/luci-go/common/errors" |
| 9 "github.com/luci/luci-go/server/router" |
| 10 "github.com/luci/luci-go/server/templates" |
| 11 |
| 12 "github.com/luci/luci-go/milo/common" |
| 13 ) |
| 14 |
| 15 // ErrorHandler renders an error page for the user. |
| 16 func ErrorHandler(c *router.Context, err error) { |
| 17 // TODO(iannucci): tag/extract other information from error, like a link
to the |
| 18 // 'container'; i.e. a build may link to its builder, a builder to its |
| 19 // master/bucket, etc. |
| 20 |
| 21 code := common.ErrorTag.In(err) |
| 22 if code == common.CodeUnknown { |
| 23 errors.Log(c.Context, err) |
| 24 } |
| 25 status := code.HTTPStatus() |
| 26 c.Writer.WriteHeader(status) |
| 27 templates.MustRender(c.Context, c.Writer, "pages/error.html", templates.
Args{ |
| 28 "Code": status, |
| 29 "Message": err.Error(), |
| 30 }) |
| 31 } |
OLD | NEW |