Documentation ¶
Index ¶
- Variables
- func BadRequest(format string, args ...interface{}) error
- func BadRequestErr(err error, opts ...Option) error
- func Errorf(code int, format string, args ...interface{}) error
- func Forbidden(format string, args ...interface{}) error
- func ForbiddenErr(err error, opts ...Option) error
- func InternalServer(format string, args ...interface{}) error
- func InternalServerErr(err error, opts ...Option) error
- func NewErr(status int, err error, opts ...Option) error
- func NotFound(format string, args ...interface{}) error
- func NotFoundErr(err error, opts ...Option) error
- func NotImplemented(format string, args ...interface{}) error
- func NotImplementedErr(err error, opts ...Option) error
- func StatusCodeError(code int, e error, opts ...Option) error
- func Unauthorized(format string, args ...interface{}) error
- func UnauthorizedErr(err error, opts ...Option) error
- func UnexpectedErr(code int, err error, opts ...Option) error
- func Wrap(status int, e error, m string, args ...interface{}) error
- func Wrapf(status int, e error, format string, args ...interface{}) error
- type Error
- type ErrorResponse
- type Messenger
- type Option
- type StackTracer
- type StatusCoder
Constants ¶
This section is empty.
Variables ¶
var ( // BadRequestDefaultMsg 400 default msg BadRequestDefaultMsg = "The request could not be completed; malformed or missing data" + seeLogs UnauthorizedDefaultMsg = "The request lacked necessary authorization to be completed. " + seeLogs // ForbiddenDefaultMsg 403 default msg ForbiddenDefaultMsg = "The request was forbidden by the certificate authority. " + seeLogs // NotFoundDefaultMsg 404 default msg NotFoundDefaultMsg = "The requested resource could not be found. " + seeLogs // InternalServerErrorDefaultMsg 500 default msg InternalServerErrorDefaultMsg = "The certificate authority encountered an Internal Server Error. " + seeLogs // NotImplementedDefaultMsg 501 default msg NotImplementedDefaultMsg = "The requested method is not implemented by the certificate authority. " + seeLogs )
Functions ¶
func BadRequest ¶
BadRequest creates a 400 error with the given format and arguments.
func BadRequestErr ¶
BadRequestErr returns an 400 error with the given error.
func ForbiddenErr ¶
ForbiddenErr returns an 403 error with the given error.
func InternalServer ¶
InternalServer creates a 500 error with the given format and arguments.
func InternalServerErr ¶
InternalServerErr returns a 500 error with the given error.
func NewErr ¶
NewErr returns a new Error. If the given error implements the StatusCoder interface we will ignore the given status.
func NotFoundErr ¶
NotFoundErr returns an 404 error with the given error.
func NotImplemented ¶
NotImplemented creates a 501 error with the given format and arguments.
func NotImplementedErr ¶
NotImplementedErr returns a 501 error with the given error.
func StatusCodeError ¶
StatusCodeError selects the proper error based on the status code.
func Unauthorized ¶
Unauthorized creates a 401 error with the given format and arguments.
func UnauthorizedErr ¶
UnauthorizedErr returns an 401 error with the given error.
func UnexpectedErr ¶
UnexpectedErr will be used when the certificate authority makes an outgoing request and receives an unhandled status code.
Types ¶
type Error ¶
Error represents the CA API errors.
func (*Error) MarshalJSON ¶
MarshalJSON implements json.Marshaller interface for the Error struct.
func (*Error) StatusCode ¶
StatusCode implements the StatusCoder interface and returns the HTTP response code.
func (*Error) UnmarshalJSON ¶
UnmarshalJSON implements json.Unmarshaler interface for the Error struct.
type ErrorResponse ¶
ErrorResponse represents an error in JSON format.
type Messenger ¶
type Messenger interface {
Message() string
}
Messenger is a friendly message interface that errors can implement.
type Option ¶
Option modifies the Error type.
func WithKeyVal ¶
WithKeyVal returns an Option that adds the given key-value pair to the Error details. This is helpful for debugging errors.
func WithMessage ¶
WithMessage returns an Option that modifies the error by overwriting the message only if it is empty.
type StackTracer ¶
type StackTracer interface {
StackTrace() errors.StackTrace
}
StackTracer must be by those errors that return an stack trace.
type StatusCoder ¶
type StatusCoder interface {
StatusCode() int
}
StatusCoder interface is used by errors that returns the HTTP response code.