errors

package
v0.1.419 Latest Latest
Warning

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

Go to latest
Published: May 2, 2024 License: Apache-2.0 Imports: 8 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 source which can be an slice of bytes, a string, a reader or a JSON decoder.

func UnmarshalErrorStatus added in v0.0.329

func UnmarshalErrorStatus(source interface{}, status int) (object *Error, err error)

UnmarshalErrorStatus reads an error from the given source and sets the given status code.

func (*Error) Code

func (e *Error) Code() string

Code returns the code of the error.

func (*Error) Details added in v0.0.329

func (e *Error) Details() interface{}

Details returns the details 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) GetDetails added in v0.0.329

func (e *Error) GetDetails() (value interface{}, ok bool)

GetDetails returns the details of the error and a flag indicating if the details have 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) GetOperationID

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

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

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) GetStatus added in v0.0.329

func (e *Error) GetStatus() (value int, ok bool)

GetStatus returns the HTTP status code of the error and a flag indicating if the status 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) OperationID

func (e *Error) OperationID() string

OperationID returns the identifier of the operation that caused the error.

func (*Error) Reason

func (e *Error) Reason() string

Reason returns the reason of the error.

func (*Error) Status added in v0.0.329

func (e *Error) Status() int

Status returns the HTTP status code.

func (*Error) String

func (e *Error) String() string

String returns a string representing 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.

Jump to

Keyboard shortcuts

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