Skip to content

Commit

Permalink
Merge pull request #15 from laironacosta/feature/error-handler-echo
Browse files Browse the repository at this point in the history
creating some generic custom errors
  • Loading branch information
engineerit2014 authored Apr 15, 2021
2 parents 7466ea1 + 6bc0daa commit 042b16b
Showing 1 changed file with 26 additions and 0 deletions.
26 changes: 26 additions & 0 deletions middleware/responses/generic_errors.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
package responses

import (
"errors"
"net/http"
)

// GenericBadRequestError implements a generic not found error. It receives the code and message as params.
func GenericBadRequestError(code string, message string) error {
return NewGenericHttpError(http.StatusBadRequest, code, errors.New(message))
}

// GenericAlreadyExistsError implements a generic not found error. It receives the code and message as params.
func GenericAlreadyExistsError(code string, message string) error {
return NewGenericHttpError(http.StatusBadRequest, code, errors.New(message))
}

// GenericNotFoundError implements a generic not found error. It receives the code and message as params.
func GenericNotFoundError(code string, message string) error {
return NewGenericHttpError(http.StatusNotFound, code, errors.New(message))
}

// GenericInternalServerError implements a generic not found error. It receives the code and message as params.
func GenericInternalServerError(code string, message string) error {
return NewGenericHttpError(http.StatusInternalServerError, code, errors.New(message))
}

0 comments on commit 042b16b

Please sign in to comment.