Skip to content

Commit 042b16b

Browse files
Merge pull request #15 from laironacosta/feature/error-handler-echo
creating some generic custom errors
2 parents 7466ea1 + 6bc0daa commit 042b16b

File tree

1 file changed

+26
-0
lines changed

1 file changed

+26
-0
lines changed
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
package responses
2+
3+
import (
4+
"errors"
5+
"net/http"
6+
)
7+
8+
// GenericBadRequestError implements a generic not found error. It receives the code and message as params.
9+
func GenericBadRequestError(code string, message string) error {
10+
return NewGenericHttpError(http.StatusBadRequest, code, errors.New(message))
11+
}
12+
13+
// GenericAlreadyExistsError implements a generic not found error. It receives the code and message as params.
14+
func GenericAlreadyExistsError(code string, message string) error {
15+
return NewGenericHttpError(http.StatusBadRequest, code, errors.New(message))
16+
}
17+
18+
// GenericNotFoundError implements a generic not found error. It receives the code and message as params.
19+
func GenericNotFoundError(code string, message string) error {
20+
return NewGenericHttpError(http.StatusNotFound, code, errors.New(message))
21+
}
22+
23+
// GenericInternalServerError implements a generic not found error. It receives the code and message as params.
24+
func GenericInternalServerError(code string, message string) error {
25+
return NewGenericHttpError(http.StatusInternalServerError, code, errors.New(message))
26+
}

0 commit comments

Comments
 (0)