exception

package
v1.3.1 Latest Latest
Warning

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

Go to latest
Published: Dec 1, 2022 License: MIT Imports: 0 Imported by: 10

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

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

A Config for Exception creation

type Error

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

Error wrap default error with exception format

func (*Error) Detail

func (e *Error) Detail() string

Detail return exception detail

func (*Error) Error

func (e *Error) Error() string

func (*Error) Title

func (e *Error) Title() string

Title return exception title

func (*Error) Type

func (e *Error) Type() Type

Type return exception type

type Exception

type Exception interface {
	Error() string
	Type() Type
	Detail() string
	Title() string
}

Exception wrap error into more informative structs

func Throw

func Throw(err error, opts ...Option) Exception

Throw new exception

type Option

type Option func(*Config)

Option when fabricating Exception

func WithDetail

func WithDetail(detail string) Option

WithDetail fabricate exception with detail

func WithTitle

func WithTitle(title string) Option

WithTitle fabricate exception with title

func WithType

func WithType(exceptionType Type) Option

WithType fabricate exception with exception type

type Type

type Type uint

Type of exception

const (
	// Unexpected throwed when there is unexpected error that not specified yet here in exception type
	Unexpected Type = iota
	// NotFound throwed when there is unexpected data missing
	NotFound
	// Duplicated throwed when there is unexpected duplicated data
	Duplicated
	// BadInput throwed when there is unexpected input received from the caller
	BadInput
	// Unauthorized throwed when there is unauthorized access from the caller
	Unauthorized
	// Forbidden throwd when there is unexpected access from the caller
	Forbidden
)

func (Type) String

func (t Type) String() string

Jump to

Keyboard shortcuts

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