package exception import ( "fmt" ) func NewApiExceptin(code int, message string) *ApiExceptin { return &ApiExceptin{ Code: code, Message: message, } } type ApiExceptin struct { HttpCode int `json:"-"` Code int `json:"code"` Message string `json:"message"` } func (e *ApiExceptin) WithHttpCode(httpCode int) *ApiExceptin { e.HttpCode = httpCode return e } func (e *ApiExceptin) Error() string { return fmt.Sprintf("[%d] %s", e.Code, e.Message) }