(err error)
| 198 | } |
| 199 | |
| 200 | func getStatusCode(err error) int { |
| 201 | rootErr := errors.Cause(err) |
| 202 | |
| 203 | switch rootErr { |
| 204 | case app.ErrNotFound: |
| 205 | return http.StatusNotFound |
| 206 | case app.ErrLoginInvalid: |
| 207 | return http.StatusUnauthorized |
| 208 | case app.ErrDuplicateEmail, app.ErrEmailRequired, app.ErrPasswordTooShort: |
| 209 | return http.StatusBadRequest |
| 210 | case app.ErrLoginRequired: |
| 211 | return http.StatusUnauthorized |
| 212 | case app.ErrBookUUIDRequired: |
| 213 | return http.StatusBadRequest |
| 214 | case app.ErrEmptyUpdate: |
| 215 | return http.StatusBadRequest |
| 216 | case app.ErrInvalidUUID: |
| 217 | return http.StatusBadRequest |
| 218 | case app.ErrDuplicateBook: |
| 219 | return http.StatusConflict |
| 220 | case app.ErrInvalidToken: |
| 221 | return http.StatusBadRequest |
| 222 | case app.ErrPasswordResetTokenExpired: |
| 223 | return http.StatusGone |
| 224 | case app.ErrPasswordConfirmationMismatch: |
| 225 | return http.StatusBadRequest |
| 226 | case app.ErrInvalidPasswordChangeInput: |
| 227 | return http.StatusBadRequest |
| 228 | case app.ErrInvalidPassword: |
| 229 | return http.StatusUnauthorized |
| 230 | case app.ErrEmailTooLong: |
| 231 | return http.StatusBadRequest |
| 232 | case app.ErrMissingToken: |
| 233 | return http.StatusBadRequest |
| 234 | case app.ErrExpiredToken: |
| 235 | return http.StatusGone |
| 236 | } |
| 237 | |
| 238 | return http.StatusInternalServerError |
| 239 | } |
| 240 | |
| 241 | // handleHTMLError writes the error to the log and sets the error message in the data. |
| 242 | func handleHTMLError(w http.ResponseWriter, r *http.Request, err error, msg string, v *views.View, d views.Data) { |
no outgoing calls
no test coverage detected