From 72b6a2e32ce4ee8d81bbc10145422bf4df8215ba Mon Sep 17 00:00:00 2001 From: WinPooh32 Date: Sat, 28 Jan 2023 17:10:23 +1000 Subject: [PATCH] Expose error messages to http response --- http/handle.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/http/handle.go b/http/handle.go index faf2dd4..fdf34c3 100644 --- a/http/handle.go +++ b/http/handle.go @@ -31,7 +31,7 @@ func magnet(next http.Handler) http.Handler { var magnet, err = metainfo.ParseMagnetUri(magnetURI) if err != nil { - http.Error(w, http.StatusText(http.StatusBadRequest), http.StatusBadRequest) + http.Error(w, err.Error(), http.StatusBadRequest) return } @@ -45,12 +45,12 @@ func path(next http.Handler) http.Handler { var path, err = url.QueryUnescape(chi.URLParam(r, "*")) if err != nil { - http.Error(w, http.StatusText(http.StatusBadRequest), http.StatusBadRequest) + http.Error(w, err.Error(), http.StatusBadRequest) return } if !govalidator.IsRequestURI("/" + path) { - http.Error(w, http.StatusText(http.StatusBadRequest), http.StatusBadRequest) + http.Error(w, "malformed url", http.StatusBadRequest) return }