apperror

package
v1.0.1-with-auth Latest Latest
Warning

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

Go to latest
Published: Mar 1, 2025 License: MIT Imports: 0 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AppError

type AppError interface {
	Error() string
	OriginalError() error
	Kind() Kind
	Origin() Origin
	OriginName() string
	BusinessCode() *BusinessCode
	ClientCode() *int
}

func New

func New(
	err error,
	msg string,
	kind Kind,
	origin Origin,
	originName string,
	bc *BusinessCode,
	clientCode *int,
) AppError

type BusinessCode

type BusinessCode string
const (
	BUSINESS_E100 BusinessCode = "E100"
	BUSINESS_E101 BusinessCode = "E101"
	BUSINESS_E102 BusinessCode = "E102"
	BUSINESS_E103 BusinessCode = "E103"
	BUSINESS_E104 BusinessCode = "E104"
	BUSINESS_E105 BusinessCode = "E105"
)

Tip: map these to your business errors so it's easier for your client to report what happened

type Kind

type Kind string
const (
	ParseErrorKind Kind = "parse_error"
	ValidationKind Kind = "validation_error"
	RestClientKind Kind = "rest_client_error"
	DatabaseKind   Kind = "database_error"
	BusinessKind   Kind = "business_error"
)

type Origin

type Origin string
const (
	WebHandlerOrigin     Origin = "web_handler"
	UseCaseOrigin        Origin = "use_case"
	UseCaseGatewayOrigin Origin = "gateway"
	RepositoryOrigin     Origin = "repository"
)

Jump to

Keyboard shortcuts

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