customer/internal/utils/client_response.go

25 lines
566 B
Go
Raw Normal View History

2023-06-22 09:36:43 +00:00
package utils
import (
"net/http"
2024-11-18 07:23:41 +00:00
"gitea.pena/PenaSide/customer/internal/errors"
2023-06-22 09:36:43 +00:00
)
var clientErrors = map[int]error{
http.StatusInternalServerError: errors.ErrInternalError,
http.StatusBadRequest: errors.ErrInvalidArgs,
http.StatusNotImplemented: errors.ErrMethodNotImplemented,
http.StatusNotFound: errors.ErrNotFound,
http.StatusForbidden: errors.ErrNoAccess,
}
func DetermineClientErrorResponse(statusCode int) error {
err, ok := clientErrors[statusCode]
if !ok {
return errors.ErrInternalError
}
return err
}