errors.go 486 B

12345678910111213141516171819202122
  1. package route
  2. var (
  3. ErrUnauthorized = newError("Unauthorized")
  4. ErrBadRequest = newError("Body invalid")
  5. ErrForbidden = newError("Forbidden")
  6. ErrNotFound = newError("Resource not found")
  7. ErrRequestTimeout = newError("Timeout")
  8. )
  9. // HTTPError is custom HTTP error for API
  10. type HTTPError struct {
  11. Message string `json:"message"`
  12. }
  13. func (e *HTTPError) Error() string {
  14. return e.Message
  15. }
  16. func newError(msg string) *HTTPError {
  17. return &HTTPError{Message: msg}
  18. }