github.com/inazumav/sing-box@v0.0.0-20230926072359-ab51429a14f1/experimental/clashapi/errors.go (about)

     1  package clashapi
     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  }