MCPcopy
hub / github.com/filebrowser/filebrowser / errToStatus

Function errToStatus

http/utils.go:30–51  ·  view source on GitHub ↗
(err error)

Source from the content-addressed store, hash-verified

28}
29
30func 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.

Callers 15

previewHandlerFunction · 0.85
handleImagePreviewFunction · 0.85
share.goFile · 0.85
users.goFile · 0.85
tusPostHandlerFunction · 0.85
tusHeadHandlerFunction · 0.85
tusPatchHandlerFunction · 0.85
tusDeleteHandlerFunction · 0.85
public.goFile · 0.85
raw.goFile · 0.85
settings.goFile · 0.85
subtitle.goFile · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected