Added completed user. Some fixes and more more more...
This commit is contained in:
parent
b96dd39795
commit
ea8ab7c0ed
33 changed files with 576 additions and 212 deletions
|
|
@ -14,17 +14,24 @@ func HandleError(err error) responses.ErrorResponse {
|
|||
|
||||
log.Println(err)
|
||||
|
||||
if errors.Is(&ie.ValidationError{}, err) {
|
||||
var validationErr *ie.ValidationError
|
||||
var readFileErr *ie.ReadFileError
|
||||
var notFoundErr *ie.NotFoundError
|
||||
var alreadyExistsErr *ie.AlreadyExistsError
|
||||
var dbErr *ie.DBError
|
||||
|
||||
switch {
|
||||
case errors.As(err, &validationErr):
|
||||
errorCode = http.StatusBadRequest
|
||||
} else if errors.Is(&ie.ReadFileError{}, err) {
|
||||
case errors.As(err, &readFileErr):
|
||||
errorCode = http.StatusInternalServerError
|
||||
} else if errors.Is(&ie.NotFoundError{}, err) {
|
||||
case errors.As(err, ¬FoundErr):
|
||||
errorCode = http.StatusNotFound
|
||||
} else if errors.Is(&ie.AlreadyExistsError{}, err) {
|
||||
case errors.As(err, &alreadyExistsErr):
|
||||
errorCode = http.StatusConflict
|
||||
} else if errors.Is(&ie.DBError{}, err) {
|
||||
case errors.As(err, &dbErr):
|
||||
errorCode = http.StatusInternalServerError
|
||||
} else {
|
||||
default:
|
||||
errorCode = http.StatusInternalServerError
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue