Documentation ¶
Index ¶
- Constants
- Variables
- func NewCreateError(name, errorMessage string) error
- func NewDeleteError(name, errorMessage string) error
- func NewErrorID() int
- func NewGetError(name, errorMessage string) error
- func NewListError(name, errorMessage string) error
- func NewNotFoundError(name string) error
- func NewUpdateError(name, errorMessage string) error
- func NewValidateError(name, reason string) error
- type Error
Constants ¶
View Source
const ( // ReasonInternal is a type about internal errors ReasonInternal = "ReasonInternal" // ReasonRequest is a type about request errors ReasonRequest = "ReasonRequest" )
defines reason types
Variables ¶
View Source
var ( // ErrorUnknownRequest defines unknown error when failed to handle a request ErrorUnknownRequest = NewFormatError(http.StatusBadRequest, ReasonRequest, "%s") // ErrorParamTypeError defines param type error ErrorParamTypeError = NewFormatError(http.StatusBadRequest, ReasonRequest, "param %s should be %s, but got %s") // ErrorParamNotFound defines request param error ErrorParamNotFound = NewFormatError(http.StatusBadRequest, ReasonRequest, "can't find param %s in request") // ErrorUrlParamNotFound defines request url query param error ErrorUrlParamNotFound = NewFormatError(http.StatusBadRequest, ReasonRequest, "can't find param %s in request url query") // ErrorHeaderNotFound defines request header error ErrorHeaderParamNotFound = NewFormatError(http.StatusBadRequest, ReasonRequest, "can't find param %s in request header") // ErrorValidationFailed defines validation failed error ErrorValidationFailed = NewFormatError(http.StatusBadRequest, ReasonRequest, "failed to validate %s: %s") // ErrorContentNotFound defines not found error ErrorContentNotFound = NewFormatError(http.StatusNotFound, ReasonRequest, "content %s not found") // ErrorQuotaExceeded defines quota exceeded error, creating or updating was not allowed ErrorQuotaExceeded = NewFormatError(http.StatusForbidden, ReasonRequest, "%s quota exceeded") ErrorAlreadyExist = NewFormatError(http.StatusConflict, ReasonRequest, "conflict: %s already exist") ErrorAuthenticationRequired = NewFormatError(http.StatusProxyAuthRequired, ReasonRequest, "authentication required") // ErrorInternalTypeError defines internal type error ErrorInternalTypeError = NewFormatError(http.StatusInternalServerError, ReasonInternal, "type of %s should be %s, but got %s") // ErrorUnknownNotFoundError defines not found error that we can't find a reason ErrorUnknownNotFoundError = NewFormatError(http.StatusInternalServerError, ReasonInternal, "content %s not found, may be it's a serious error") // ErrorUnknownInternal defines any internal error and not one of above errors ErrorUnknownInternal = NewFormatError(http.StatusInternalServerError, ReasonInternal, "unknown error: %s") // ErrorCreateFailed defines error that failed creating of something. ErrorCreateFailed = NewFormatError(http.StatusBadRequest, ReasonInternal, "failed to create %s: %s") // ErrorUpdateFailed defines error that failed updating of something. ErrorUpdateFailed = NewFormatError(http.StatusBadRequest, ReasonInternal, "failed to update %s: %s") // ErrorDeleteFailed defines error that failed deleting of something. ErrorDeleteFailed = NewFormatError(http.StatusBadRequest, ReasonInternal, "failed to delete %s: %s") // ErrorGetFailed defines error that failed geting of something. ErrorGetFailed = NewFormatError(http.StatusBadRequest, ReasonInternal, "failed to get %s: %s") // ErrorListFailed defines error that failed listing of something. ErrorListFailed = NewFormatError(http.StatusBadRequest, ReasonInternal, "failed to list %s: %s") )
Functions ¶
func NewCreateError ¶
func NewDeleteError ¶
func NewGetError ¶
func NewListError ¶
func NewNotFoundError ¶
func NewUpdateError ¶
func NewValidateError ¶
NewValidateError creates new ErrorValidationFailed
Types ¶
type Error ¶
type Error struct { ID int `json:"id,omitempty"` Code int `json:"code,omitempty"` Reason string `json:"reason,omitempty"` Message string `json:"message"` Detail string `json:"detail,omitempty"` // contains filtered or unexported fields }
Error defines error with code
func NewFormatError ¶
NewFormatError creates a format error
func NewStaticError ¶
NewStaticError creates a static error
func (*Error) AppendErrorDetail ¶
AppendErrorDetail returns a byte slice joined err, cmd and pc in ErrorDetail.
func (*Error) ErrorDetail ¶
Click to show internal directories.
Click to hide internal directories.