Documentation ¶
Index ¶
- Constants
- func MarshalError(object *Error, target interface{}) 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) Error() string
- func (e *Error) GetCode() (value string, ok bool)
- func (e *Error) GetHREF() (value string, ok bool)
- func (e *Error) GetID() (value string, ok bool)
- func (e *Error) GetReason() (value string, ok bool)
- func (e *Error) HREF() string
- func (e *Error) ID() string
- func (e *Error) Kind() string
- func (e *Error) Reason() string
- type 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 destination which can be an slice of bytes, a string, a reader or a JSON decoder.
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 which can be an slice of bytes, a string, a reader or a JSON decoder.
func (*Error) GetCode ¶
GetCode returns the link of the error and a flag indicating if the code has 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.
type ErrorBuilder ¶
type ErrorBuilder struct {
// contains filtered or unexported fields
}
ErrorBuilder is a builder for the error type.
func (*ErrorBuilder) Build ¶
func (e *ErrorBuilder) Build() (*Error, error)
Build builds a new error type or returns an error.
func (*ErrorBuilder) Code ¶
func (e *ErrorBuilder) Code(code string) *ErrorBuilder
Code sets the cpde field for the ErrorBuilder
func (*ErrorBuilder) HREF ¶
func (e *ErrorBuilder) HREF(href string) *ErrorBuilder
HREF sets the href field for the ErrorBuilder
func (*ErrorBuilder) ID ¶
func (e *ErrorBuilder) ID(id string) *ErrorBuilder
ID sets the id field for the ErrorBuilder
func (*ErrorBuilder) Reason ¶
func (e *ErrorBuilder) Reason(reason string) *ErrorBuilder
Reason sets the reason field for the ErrorBuilder