Documentation ¶
Index ¶
Constants ¶
const ( ErrorTypeNone = iota ErrorTypeInternal = iota ErrorTypeClient = iota )
Variables ¶
This section is empty.
Functions ¶
func ChainError ¶
ChainError will combine the error message and the message together in an easy to read manner.
Types ¶
type BasicResponse ¶
type BasicResponse struct {
Success bool `json:"success"`
}
BasicResponse represents a response with a simple true/false success field.
func NewSuccessResponse ¶
func NewSuccessResponse() (int, BasicResponse)
NewSuccessResponse returns an http OK status and a success basic response.
type CustomError ¶
type CustomError struct { Type int // contains filtered or unexported fields }
CustomError is an error with an added type field to determine how it should be handled.
func ClientError ¶
func ClientError(message string) CustomError
ClientError returns a CustomError with type ErrorTypeClient and the provided message.
func InternalError ¶
func InternalError() CustomError
InternalError returns a CustomError with type ErrorTypeInternal and an internal error message.
type DataResponse ¶
type DataResponse struct { Success bool `json:"success"` Data interface{} `json:"data"` }
DataResponse represents a response with a true/false success field and generic data.
func NewSuccessDataResponse ¶
func NewSuccessDataResponse(data interface{}) (int, DataResponse)
NewSuccessDataResponse return an http OK status and a new DataResponse with the provided data.
type ErrorResponse ¶
ErrorResponse represents a response with a true/false success field and an error message.
func NewBadRequestResponse ¶
func NewBadRequestResponse(err string) (int, ErrorResponse)
NewBadRequestResponse returns an http BadRequest status and a new error response with the provided error message.
func NewErrorResponse ¶
func NewErrorResponse(err string) ErrorResponse
NewErrorResponse creates a new ErrorResponse with a false success field and the provided error message.
func NewInsufficientPermissionsErrorResponse ¶
func NewInsufficientPermissionsErrorResponse() (int, ErrorResponse)
NewInsufficientPermissionsErrorResponse returns an http StatusForbidden status and a new error response with an insufficient permissions error message.
func NewInternalServerErrorResponse ¶
func NewInternalServerErrorResponse() (int, ErrorResponse)
NewInternalServerErrorResponse returns an http StatusInternalServerError status and a new error response with an internal error message.