errors

package
v0.1.81 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 16, 2020 License: Apache-2.0 Imports: 7 Imported by: 9

Documentation

Index

Constants

View Source
const ErrorKind = "Error"

Error kind is the name of the type used to represent errors.

View Source
const ErrorNilKind = "ErrorNil"

ErrorNilKind is the name of the type used to nil errors.

Variables

This section is empty.

Functions

func MarshalError

func MarshalError(e *Error, writer io.Writer) error

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.

func SendPanic

func SendPanic(w http.ResponseWriter, r *http.Request)

SendPanic sends a panic error response to the client, but it doesn't end the process. This methods is used internaly and no backwards compatibily is guaranteed.

Types

type Error

type Error struct {
	// contains filtered or unexported fields
}

Error represents errors.

func UnmarshalError

func UnmarshalError(source interface{}) (object *Error, err error)

UnmarshalError reads an error from the given which can be an slice of bytes, a string, a reader or a JSON decoder.

func (*Error) Code

func (e *Error) Code() string

Code returns the code of the error.

func (*Error) Error

func (e *Error) Error() string

Error is the implementation of the error interface.

func (*Error) GetCode

func (e *Error) GetCode() (value string, ok bool)

GetCode returns the link of the error and a flag indicating if the code has a value.

func (*Error) GetHREF

func (e *Error) GetHREF() (value string, ok bool)

GetHREF returns the link of the error and a flag indicating if the link has a value.

func (*Error) GetID

func (e *Error) GetID() (value string, ok bool)

GetID returns the identifier of the error and a flag indicating if the identifier has a value.

func (*Error) GetReason

func (e *Error) GetReason() (value string, ok bool)

GetReason returns the link of the error and a flag indicating if the reason has a value.

func (*Error) HREF

func (e *Error) HREF() string

HREF returns the link to the error.

func (*Error) ID

func (e *Error) ID() string

ID returns the identifier of the error.

func (*Error) Kind

func (e *Error) Kind() string

Kind returns the name of the type of the error.

func (*Error) Reason

func (e *Error) Reason() string

Reason returns the reason of 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 returns a new ErrorBuilder

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

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL