Skip to content

Commit b8b1fe5

Browse files
committed
Refactor errors status codes to use http
1 parent 14facf1 commit b8b1fe5

1 file changed

Lines changed: 4 additions & 3 deletions

File tree

errors.go

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ package sqliteadmin
33
import (
44
"errors"
55
"fmt"
6+
"net/http"
67
)
78

89
var (
@@ -22,13 +23,13 @@ func (e ApiError) Error() string {
2223
}
2324

2425
func apiErrUnauthorized() ApiError {
25-
return ApiError{StatusCode: 401, Message: "Invalid credentials"}
26+
return ApiError{StatusCode: http.StatusUnauthorized, Message: "Invalid credentials"}
2627
}
2728

2829
func apiErrBadRequest(details string) ApiError {
29-
return ApiError{StatusCode: 400, Message: "Bad request: " + details}
30+
return ApiError{StatusCode: http.StatusBadRequest, Message: "Bad request: " + details}
3031
}
3132

3233
func apiErrSomethingWentWrong() ApiError {
33-
return ApiError{StatusCode: 500, Message: "Something went wrong"}
34+
return ApiError{StatusCode: http.StatusInternalServerError, Message: "Something went wrong"}
3435
}

0 commit comments

Comments
 (0)