errors

package
v0.0.0-...-7e06a17 Latest Latest
Warning

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

Go to latest
Published: Jun 3, 2021 License: MIT Imports: 1 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ServerErrorCode       = ErrorCode("server_error")
	BadRequestErrorCode   = ErrorCode("bad_request")
	UnauthorizedErrorCode = ErrorCode("unauthorized")
	NotFoundErrorCode     = ErrorCode("not_found")
	ConflictErrorCode     = ErrorCode("conflict")
)

Enumerated values for ErrorCode

Variables

This section is empty.

Functions

This section is empty.

Types

type Error

type Error struct {
	Err        error
	StatusCode int
	Code       ErrorCode
	Message    string
}

Error respresents an application error

func NewBadRequestError

func NewBadRequestError(message string) *Error

NewBadRequestError create a new application error with status 400

func NewConflictError

func NewConflictError(message string) *Error

NewConflictError create a new application error with status 409

func NewInternalServerError

func NewInternalServerError(err error) *Error

NewInternalServerError create a new application error with status 500

func NewNotFoundError

func NewNotFoundError() *Error

NewNotFoundError create a new application error with status 404

func NewUnauthorizedError

func NewUnauthorizedError() *Error

NewUnauthorizedError create a new application error with status 401

func (*Error) Error

func (e *Error) Error() string

func (*Error) WithWrap

func (e *Error) WithWrap(err error) *Error

WithWrap wraps native error into application error

type ErrorCode

type ErrorCode string

ErrorCode represents different application error codes.

Jump to

Keyboard shortcuts

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