MCPcopy
hub / github.com/writefreely/writefreely / handleError

Method handleError

handle.go:859–881  ·  view source on GitHub ↗
(w http.ResponseWriter, r *http.Request, err error)

Source from the content-addressed store, hash-verified

857}
858
859func (h *Handler) handleError(w http.ResponseWriter, r *http.Request, err error) {
860 if err == nil {
861 return
862 }
863
864 if err, ok := err.(impart.HTTPError); ok {
865 if err.Status >= 300 && err.Status < 400 {
866 sendRedirect(w, err.Status, err.Message)
867 return
868 }
869
870 // if strings.Contains(r.Header.Get("Accept"), "text/html") {
871 impart.WriteError(w, err)
872 // }
873 return
874 }
875
876 if IsJSON(r) {
877 impart.WriteError(w, impart.HTTPError{http.StatusInternalServerError, "This is an unhelpful error message for a miscellaneous internal error."})
878 return
879 }
880 h.errors.InternalServerError.ExecuteTemplate(w, "base", pageForReq(h.app.App(), r))
881}
882
883func (h *Handler) handleTextError(w http.ResponseWriter, r *http.Request, err error) {
884 if err == nil {

Callers 3

UserAllMethod · 0.95
AllMethod · 0.95
AllReaderMethod · 0.95

Calls 4

sendRedirectFunction · 0.85
IsJSONFunction · 0.85
pageForReqFunction · 0.85
AppMethod · 0.65

Tested by

no test coverage detected