-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #15 from laironacosta/feature/error-handler-echo
creating some generic custom errors
- Loading branch information
Showing
1 changed file
with
26 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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)) | ||
} |