github.com/metacubex/mihomo@v1.18.5/hub/route/errors.go (about)

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