Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-pages.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKamil TrzciƄski <ayufan@ayufan.eu>2020-10-27 06:49:07 +0300
committerVladimir Shushlin <vshushlin@gitlab.com>2020-10-27 06:49:07 +0300
commit5be346a94902c7147f3b1571e6ebb2c1f4e98eb8 (patch)
tree1e6328dd475c3578a3910181d6e2a26f20285bef /internal/httperrors
parentb382faeec6491bb544d33549570610a476f597b7 (diff)
Properly handle processing failures with `5xx`
Prior to this change ALL processing failures unrelated to "file missing" would return `404`. This is inaccurate. Processing failures are failure of GitLab Pages and `500` should be returned in such cases.
Diffstat (limited to 'internal/httperrors')
-rw-r--r--internal/httperrors/httperrors.go14
1 files changed, 14 insertions, 0 deletions
diff --git a/internal/httperrors/httperrors.go b/internal/httperrors/httperrors.go
index 1ae5224b..476d270c 100644
--- a/internal/httperrors/httperrors.go
+++ b/internal/httperrors/httperrors.go
@@ -3,6 +3,10 @@ package httperrors
import (
"fmt"
"net/http"
+
+ log "github.com/sirupsen/logrus"
+
+ "gitlab.com/gitlab-org/labkit/errortracking"
)
type content struct {
@@ -177,6 +181,16 @@ func Serve500(w http.ResponseWriter) {
serveErrorPage(w, content500)
}
+// Serve500WithRequest returns a 500 error response / HTML page to the http.ResponseWriter
+func Serve500WithRequest(w http.ResponseWriter, r *http.Request, reason string, err error) {
+ log.WithFields(log.Fields{
+ "host": r.Host,
+ "path": r.URL.Path,
+ }).WithError(err).Error(reason)
+ errortracking.Capture(err, errortracking.WithRequest(r))
+ serveErrorPage(w, content500)
+}
+
// Serve502 returns a 502 error response / HTML page to the http.ResponseWriter
func Serve502(w http.ResponseWriter) {
serveErrorPage(w, content502)