feat: add new error code type

This commit is contained in:
Michael Barz
2023-11-25 10:22:41 +01:00
committed by Florian Schade
parent fdb3572cc0
commit 2668ca664a
@@ -59,6 +59,8 @@ const (
Unauthenticated
// PreconditionFailed the request cannot be made and this error response is sent back
PreconditionFailed
// ItemIsLocked The item is locked by another process. Try again later.
ItemIsLocked
)
var errorCodes = [...]string{
@@ -80,6 +82,7 @@ var errorCodes = [...]string{
"quotaLimitReached",
"unauthenticated",
"preconditionFailed",
"itemIsLocked",
}
// New constructs a new errorcode.Error
@@ -129,6 +132,8 @@ func (e Error) Render(w http.ResponseWriter, r *http.Request) {
status = http.StatusConflict
case NotAllowed:
status = http.StatusMethodNotAllowed
case ItemIsLocked:
status = http.StatusLocked
default:
status = http.StatusInternalServerError
}