vader

package module
v0.1.2 Latest Latest
Warning

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

Go to latest
Published: Jul 23, 2021 License: MIT Imports: 0 Imported by: 2

README

Go Report Card GoDev GitHub release

Vader

DDD error wrapper

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewDomainErrorHandler

func NewDomainErrorHandler() *errorHandler

NewDomainErrorHandler returns an error handler with group of domain

func NewHandlerErrorHandler

func NewHandlerErrorHandler() *errorHandler

NewHandlerErrorHandler returns an error handler with group of handler

func NewRepoErrorHandler

func NewRepoErrorHandler() *errorHandler

NewRepoErrorHandler returns an error handler with group of repo

func NewServiceErrorHandler

func NewServiceErrorHandler() *errorHandler

NewServiceErrorHandler returns an error handler with group of service

Types

type Error

type Error interface {
	// Error returns the string representation of the error
	Error() string
	// Checks if the error has group of server
	IsServer() bool
	// Checks if the error has group of repository
	IsRepository() bool
	// Checks if the error has group of service
	IsService() bool
	// Checks if the error has group of handler
	IsHandler() bool
	// Checks if the error has group of domain
	IsDomain() bool
	// Checks if the error has kind of not found
	IsNotFound() bool
	// Checks if the error has kind of internal
	IsInternal() bool
	// Checks if the error has kind of bad request
	IsBadRequest() bool
	// Checks if the error has kind of alredy exists
	IsAlredyExists() bool
	// Returns the group of the error
	GetGroup() string
	// Returns the kind of the error
	GetKind() string
	// Returns the code of the error
	GetCode() int
}

Error interface

func AlredyExists added in v0.1.2

func AlredyExists(msg string) Error

AlredyExistsError returns an alredy exists error

func BadRequest

func BadRequest(msg string) Error

BadRequest returns a bad request error

func Conflict added in v0.1.2

func Conflict(msg string) Error

Conflict returns a conflict error

func Forbidden added in v0.1.2

func Forbidden(msg string) Error

Forbidden returns a forbidden error

func Generic

func Generic(msg string) Error

Generic returns a generic error

func Internal added in v0.1.2

func Internal(msg string) Error

InternalError returns an internal error

func NewError

func NewError(msg string, status int) Error

NewError returns a new error with status code

func NotFound

func NotFound(msg string) Error

NotFound returns a not found error

func Unauthorized

func Unauthorized(msg string) Error

UnauthorizedError returns an unauthorized error

func UnprocessableEntity added in v0.1.2

func UnprocessableEntity(msg string) Error

UnprocessableEntityError returns an unprocessable entity error

type ErrorHadler

type ErrorHadler interface {
	// Returns a generic error with the group of the handler
	Generic(msg string) Error
	// Returns an error with the group of the handler and kind of not found
	NotFound(msg string) Error
	// Returns an error with the group of the handler and kind of internal
	Internal(msg string) Error
	// Returns an error with the group of the handler and kind of bad request
	BadRequest(msg string) Error
	// Returns an error with the group of the handler and kind of unauthorized
	Unauthorized(msg string) Error
	// Returns an error with the group of the handler and kind of alredy exists
	AlreadyExists(msg string) Error
	// Returns an error with the group of the handler and kind of unprocessable entity
	UnprocessableEntity(msg string) Error
	// Returns an error with the group of the handler and kind of forbidden
	Forbidden(msg string) Error
	// Returns an error with the group of the handler and kind of conflict
	Conflict(msg string) Error
}

ErrorHandler has a pre defined group

Jump to

Keyboard shortcuts

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