(w http.ResponseWriter, r *http.Request, err error)
| 857 | } |
| 858 | |
| 859 | func (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 | |
| 883 | func (h *Handler) handleTextError(w http.ResponseWriter, r *http.Request, err error) { |
| 884 | if err == nil { |
no test coverage detected