Documentation ¶
Index ¶
- Constants
- type ErrorCode
- type ErrorResponse
- func NewBadRequestError(msg string, args ...any) *ErrorResponse
- func NewEndpointNotFound(msg string, args ...any) *ErrorResponse
- func NewInternalError(msg string, args ...any) *ErrorResponse
- func NewInvalidParameterValueError(msg string, args ...any) *ErrorResponse
- func NewResourceAlreadyExistsError(msg string, args ...any) *ErrorResponse
- func NewResourceDoesNotExistError(msg string, args ...any) *ErrorResponse
Constants ¶
const ( ErrorCodeInternalError = "INTERNAL_ERROR" ErrorCodeBadRequest = "BAD_REQUEST" ErrorCodeInvalidParameterValue = "INVALID_PARAMETER_VALUE" ErrorCodeEndpointNotFound = "ENDPOINT_NOT_FOUND" ErrorCodeResourceAlreadyExists = "RESOURCE_ALREADY_EXISTS" ErrorCodeResourceDoesNotExist = "RESOURCE_DOES_NOT_EXIST" )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ErrorResponse ¶
type ErrorResponse struct { Message string `json:"message"` ErrorCode ErrorCode `json:"error_code"` StatusCode int `json:"-"` OriginalError error `json:"-"` }
ErrorResponse represents error response object.
func NewBadRequestError ¶
func NewBadRequestError(msg string, args ...any) *ErrorResponse
NewBadRequestError creates new Response object with ErrorCodeBadRequest.
func NewEndpointNotFound ¶
func NewEndpointNotFound(msg string, args ...any) *ErrorResponse
NewEndpointNotFound creates new Response object with ErrorCodeEndpointNotFound.
func NewInternalError ¶
func NewInternalError(msg string, args ...any) *ErrorResponse
NewInternalError creates new Response object with ErrorCodeInternalError.
func NewInvalidParameterValueError ¶
func NewInvalidParameterValueError(msg string, args ...any) *ErrorResponse
NewInvalidParameterValueError creates new Response object with ErrorCodeInternalError.
func NewResourceAlreadyExistsError ¶
func NewResourceAlreadyExistsError(msg string, args ...any) *ErrorResponse
NewResourceAlreadyExistsError creates new Response object with ErrorCodeResourceAlreadyExists.
func NewResourceDoesNotExistError ¶
func NewResourceDoesNotExistError(msg string, args ...any) *ErrorResponse
NewResourceDoesNotExistError creates new Response object with ErrorCodeResourceDoesNotExist.
func (*ErrorResponse) Error ¶
func (e *ErrorResponse) Error() string
Error provides error interface to be compatible with std errors.
func (*ErrorResponse) WithError ¶
func (e *ErrorResponse) WithError(err error)
WithError stores the original error which actually caused the problem.