From 695c5d6bf82f5a5c58aa0a22b4911439f08a80fb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jes=C3=BAs=20Espino?= Date: Thu, 14 Jun 2018 09:00:40 +0200 Subject: MM-10863: Handle non-API errors with redirect to webapp (#8943) * MM-10863: Handle non-API errors with redirect to webapp * Properly shutdown the app in the new test --- web/handlers.go | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'web/handlers.go') diff --git a/web/handlers.go b/web/handlers.go index aac88aa3a..fe77241e3 100644 --- a/web/handlers.go +++ b/web/handlers.go @@ -157,8 +157,12 @@ func (h Handler) ServeHTTP(w http.ResponseWriter, r *http.Request) { c.Err.IsOAuth = false } - w.WriteHeader(c.Err.StatusCode) - w.Write([]byte(c.Err.ToJson())) + if IsApiCall(r) || len(r.Header.Get("X-Mobile-App")) > 0 { + w.WriteHeader(c.Err.StatusCode) + w.Write([]byte(c.Err.ToJson())) + } else { + utils.RenderWebAppError(w, r, c.Err, c.App.AsymmetricSigningKey()) + } if c.App.Metrics != nil { c.App.Metrics.IncrementHttpError() -- cgit v1.2.3-1-g7c22