(err error)
| 28 | } |
| 29 | |
| 30 | func errToStatus(err error) int { |
| 31 | switch { |
| 32 | case err == nil: |
| 33 | return http.StatusOK |
| 34 | case os.IsPermission(err): |
| 35 | return http.StatusForbidden |
| 36 | case os.IsNotExist(err), errors.Is(err, libErrors.ErrNotExist): |
| 37 | return http.StatusNotFound |
| 38 | case os.IsExist(err), errors.Is(err, libErrors.ErrExist): |
| 39 | return http.StatusConflict |
| 40 | case errors.Is(err, libErrors.ErrPermissionDenied): |
| 41 | return http.StatusForbidden |
| 42 | case errors.Is(err, libErrors.ErrInvalidRequestParams): |
| 43 | return http.StatusBadRequest |
| 44 | case errors.Is(err, libErrors.ErrRootUserDeletion): |
| 45 | return http.StatusForbidden |
| 46 | case errors.Is(err, imgErrors.ErrImageTooLarge): |
| 47 | return http.StatusRequestEntityTooLarge |
| 48 | default: |
| 49 | return http.StatusInternalServerError |
| 50 | } |
| 51 | } |
| 52 | |
| 53 | // This is an adaptation if http.StripPrefix in which we don't |
| 54 | // return 404 if the page doesn't have the needed prefix. |
no outgoing calls
no test coverage detected