code: func (h *JSONWriter) WriteErrorCode(w http.ResponseWriter, r *http.Request, code int, err interface{}) {
  	if err == nil {
  		err = toError(err)
  	}
  
  	if code == 0 {
  		code = http.StatusInternalServerError
  	}
  
  	// All errors land here, so it's a really good idea to do the logging here as well!
  	h.Reporter(h.logger, "An error occurred while handling a request")(w, r, code, toError(err))
  
  	w.Header().Set("Content-Type", "application/json")
  	w.WriteHeader(code)
  
  	// Enhancing must happen after logging or context will be lost.
  	if h.ErrorEnhancer != nil {
  		err = h.ErrorEnhancer(r, toError(err))
  	}
  
  	if err := json.NewEncoder(w).Encode(err); err != nil {
  		// There was an error, but there's actually not a lot we can do except log that this happened.
  		h.Reporter(h.logger, "Could not write jsonError to response writer")(w, r, code, errors.WithStack(err))
  	}
  }
docs: // WriteErrorCode writes an error to ResponseWriter and forces an error code.