Documentation ¶
Index ¶
Constants ¶
View Source
const ( Invalid Code = -1 Ok = 0 InvalidParams = http.StatusBadRequest BadRequest = http.StatusBadRequest NotFound = http.StatusNotFound TooManyRequests = http.StatusTooManyRequests Internal = http.StatusInternalServerError // HTTPCodeUpperBound is a bound under which any Code should have the same meaning with the http status code. HTTPCodeUpperBound = Code(1000) PrintHelpUsage = 1001 ClusterAlreadyExists = 1002 )
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Code ¶
type Code int
func GetCauseCode ¶
func (Code) ToHTTPCode ¶
ToHTTPCode converts the Code to http code. The Code below the HTTPCodeUpperBound has the same meaning as the http status code. However, for the other codes, we should define the conversion rules by ourselves.
type CodeError ¶
type CodeError interface { error Code() Code // WithCausef should generate a new CodeError instance with the provided cause details. WithCausef(format string, a ...any) CodeError // WithCause should generate a new CodeError instance with the provided cause details. WithCause(cause error) CodeError }
CodeError is an error with code.
func NewCodeError ¶
NewCodeError creates a base CodeError definition. The provided code should be defined in the code.go in this package.
Click to show internal directories.
Click to hide internal directories.