Documentation ¶
Index ¶
- Constants
- func MarshalError(e *Error, writer io.Writer) error
- func SendError(w http.ResponseWriter, r *http.Request, object *Error)
- func SendInternalServerError(w http.ResponseWriter, r *http.Request)
- func SendMethodNotAllowed(w http.ResponseWriter, r *http.Request)
- func SendNotFound(w http.ResponseWriter, r *http.Request)
- func SendPanic(w http.ResponseWriter, r *http.Request)
- type Error
- func (e *Error) Code() string
- func (e *Error) Details() interface{}
- func (e *Error) Error() string
- func (e *Error) GetCode() (value string, ok bool)
- func (e *Error) GetDetails() (value interface{}, ok bool)
- func (e *Error) GetHREF() (value string, ok bool)
- func (e *Error) GetID() (value string, ok bool)
- func (e *Error) GetOperationID() (value string, ok bool)
- func (e *Error) GetReason() (value string, ok bool)
- func (e *Error) GetStatus() (value int, ok bool)
- func (e *Error) GetTimestamp() (value *time.Time, ok bool)
- func (e *Error) HREF() string
- func (e *Error) ID() string
- func (e *Error) Kind() string
- func (e *Error) OperationID() string
- func (e *Error) Reason() string
- func (e *Error) Status() int
- func (e *Error) String() string
- func (e *Error) Timestamp() *time.Time
- type ErrorBuilder
- func (b *ErrorBuilder) Build() (result *Error, err error)
- func (b *ErrorBuilder) Code(value string) *ErrorBuilder
- func (b *ErrorBuilder) Copy(object *Error) *ErrorBuilder
- func (b *ErrorBuilder) Details(value interface{}) *ErrorBuilder
- func (b *ErrorBuilder) HREF(value string) *ErrorBuilder
- func (b *ErrorBuilder) ID(value string) *ErrorBuilder
- func (b *ErrorBuilder) OperationID(value string) *ErrorBuilder
- func (b *ErrorBuilder) Reason(value string) *ErrorBuilder
- func (b *ErrorBuilder) Status(value int) *ErrorBuilder
- func (b *ErrorBuilder) Timestamp(value *time.Time) *ErrorBuilder
Constants ¶
const ErrorKind = "Error"
Error kind is the name of the type used to represent errors.
const ErrorNilKind = "ErrorNil"
ErrorNilKind is the name of the type used to nil errors.
Variables ¶
This section is empty.
Functions ¶
func MarshalError ¶
MarshalError writes an error to the given writer.
func SendError ¶
func SendError(w http.ResponseWriter, r *http.Request, object *Error)
SendError writes a given error and status code to a response writer. if an error occurred it will log the error and exit. This methods is used internaly and no backwards compatibily is guaranteed.
func SendInternalServerError ¶
func SendInternalServerError(w http.ResponseWriter, r *http.Request)
SendInternalServerError sends a generic 500 error.
func SendMethodNotAllowed ¶
func SendMethodNotAllowed(w http.ResponseWriter, r *http.Request)
SendMethodNotAllowed sends a generic 405 error.
func SendNotFound ¶
func SendNotFound(w http.ResponseWriter, r *http.Request)
SendNotFound sends a generic 404 error.
Types ¶
type Error ¶
type Error struct {
// contains filtered or unexported fields
}
Error represents errors.
func UnmarshalError ¶
UnmarshalError reads an error from the given source which can be an slice of bytes, a string, a reader or a JSON decoder.
func UnmarshalErrorStatus ¶ added in v0.0.329
UnmarshalErrorStatus reads an error from the given source and sets the given status code.
func (*Error) Details ¶ added in v0.0.329
func (e *Error) Details() interface{}
Details returns the details of the error
func (*Error) Error ¶
Error is the implementation of the error interface. Details are intentionally left out as there is no guarantee of their type
func (*Error) GetCode ¶
GetCode returns the link of the error and a flag indicating if the code has a value.
func (*Error) GetDetails ¶ added in v0.0.329
GetDetails returns the details of the error and a flag indicating if the details have a value.
func (*Error) GetHREF ¶
GetHREF returns the link of the error and a flag indicating if the link has a value.
func (*Error) GetID ¶
GetID returns the identifier of the error and a flag indicating if the identifier has a value.
func (*Error) GetOperationID ¶
GetOperationID returns the identifier of the operation that caused the error and a flag indicating if that identifier does have a value.
func (*Error) GetReason ¶
GetReason returns the link of the error and a flag indicating if the reason has a value.
func (*Error) GetStatus ¶ added in v0.0.329
GetStatus returns the HTTP status code of the error and a flag indicating if the status has a value.
func (*Error) GetTimestamp ¶ added in v0.1.440
GetTimestamp returns the timestamp of the error and a flag indicating if the timestamp have a value.
func (*Error) OperationID ¶
OperationID returns the identifier of the operation that caused the error.
type ErrorBuilder ¶
type ErrorBuilder struct {
// contains filtered or unexported fields
}
ErrorBuilder is a builder for the error type.
func NewError ¶
func NewError() *ErrorBuilder
NewError creates a new builder that can then be used to create error objects.
func (*ErrorBuilder) Build ¶
func (b *ErrorBuilder) Build() (result *Error, err error)
Build uses the information stored in the builder to create a new error object.
func (*ErrorBuilder) Code ¶
func (b *ErrorBuilder) Code(value string) *ErrorBuilder
Code sets the code of the error.
func (*ErrorBuilder) Copy ¶ added in v0.0.329
func (b *ErrorBuilder) Copy(object *Error) *ErrorBuilder
Copy copies the attributes of the given error into this builder, discarding any previous values.
func (*ErrorBuilder) Details ¶ added in v0.0.329
func (b *ErrorBuilder) Details(value interface{}) *ErrorBuilder
Details sets additional details of the error.
func (*ErrorBuilder) HREF ¶
func (b *ErrorBuilder) HREF(value string) *ErrorBuilder
HREF sets the link of the error.
func (*ErrorBuilder) ID ¶
func (b *ErrorBuilder) ID(value string) *ErrorBuilder
ID sets the identifier of the error.
func (*ErrorBuilder) OperationID ¶
func (b *ErrorBuilder) OperationID(value string) *ErrorBuilder
OperationID sets the identifier of the operation that caused the error.
func (*ErrorBuilder) Reason ¶
func (b *ErrorBuilder) Reason(value string) *ErrorBuilder
Reason sets the reason of the error.
func (*ErrorBuilder) Status ¶ added in v0.0.329
func (b *ErrorBuilder) Status(value int) *ErrorBuilder
Status sets the HTTP status code.
func (*ErrorBuilder) Timestamp ¶ added in v0.1.440
func (b *ErrorBuilder) Timestamp(value *time.Time) *ErrorBuilder
Timestamp sets the moment when it happened.