error

package
v0.0.0-...-1d97044 Latest Latest
Warning

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

Go to latest
Published: May 13, 2020 License: MIT Imports: 6 Imported by: 2

README

error

import "github.com/ver13/ava/pkg/common/error"

The errors provides an easy way to annotate errors without losing the original error context.

Documentation

Index

Constants

View Source
const RetrieveCallDefault = 3

Variables

View Source
var (
	StatusGroupUnknown    = statusGroupUnknown
	StatusSubgroupUnknown = statusSubgroupUnknown
)

Functions

func ParseGroup

func ParseGroup(name string) (Group, *Error)

ParseGroup attempts to convert a string to a Group

func ParseSubgroup

func ParseSubgroup(name string) (Subgroup, *Error)

ParseSubgroup attempts to convert a string to a Subgroup

func StatusTextFunc

func StatusTextFunc(code int) string

Types

type CallInfo

type CallInfo struct {
	PackageName string
	FileName    string
	FuncName    string
	Line        int
}

func RetrieveCallInfo

func RetrieveCallInfo() *CallInfo

retrieves the stack trace of the current call in runtime with 3 skip step

func RetrieveCallInfoSkip

func RetrieveCallInfoSkip(skip int) *CallInfo

retrieves the stack trace of the current call in runtime with n skip step

type Error

type Error struct {
	Group    Group
	Subgroup Subgroup

	Err error

	Code    int
	Message string
	Details string

	Info *CallInfo
}

Error

func GroupTypeUnknown

func GroupTypeUnknown(e error, details interface{}) *Error

GroupTypeUnknown is a AVA Error

func GroupTypeUnknownSkip

func GroupTypeUnknownSkip(e error, details interface{}, skip int) *Error

GroupTypeUnknownSkip is a AVA Error

func SubgroupTypeUnknown

func SubgroupTypeUnknown(e error, details interface{}) *Error

SubgroupTypeUnknown is a AVA Error

func SubgroupTypeUnknownSkip

func SubgroupTypeUnknownSkip(e error, details interface{}, skip int) *Error

SubgroupTypeUnknownSkip is a AVA Error

func (*Error) Error

func (e *Error) Error() string

func (*Error) Println

func (e *Error) Println() string

func (*Error) String

func (e *Error) String() string

func (*Error) ToJSON

func (e *Error) ToJSON() string

type ErrorHTTP

type ErrorHTTP struct {
	HTTPStatus int    `json:"status"`
	Code       int    `json:"code"`
	Message    string `json:"message"`
}

ErrorHTTP contains custom code, errors message, and HTTP status code.

func (*ErrorHTTP) Error

func (e *ErrorHTTP) Error() string

Error return response for the Error HTTP.

func (*ErrorHTTP) ToJSON

func (e *ErrorHTTP) ToJSON() string

ToJSON returns JSON string for a ErrorHTTP.

func (*ErrorHTTP) WriteToResponse

func (e *ErrorHTTP) WriteToResponse(w http.ResponseWriter)

WriteToResponse writes response for the Error HTTP.

type ErrorHTTPI

type ErrorHTTPI interface {
	ToJSON() string
	Error() string
	WriteToResponse(w http.ResponseWriter)
}

AVA HTTP Error Interface

type ErrorI

type ErrorI interface {
	Error() string
	Println() string
	String() string
	ToJSON() string
}

AVA Error Interface

type Group

type Group int32

Group x ENUM( General Model Serializer Encoder Server Config Logger File Blockchain Database Http Microservice MessageCoder Time ApiTime Transport Compress IO Crypto QR Validator String Utils Client GeneratorEnum Router Registry Tools Unknown )

const (
	// GroupGeneral is a Group of type General
	GroupGeneral Group = iota
	// GroupModel is a Group of type Model
	GroupModel
	// GroupSerializer is a Group of type Serializer
	GroupSerializer
	// GroupEncoder is a Group of type Encoder
	GroupEncoder
	// GroupServer is a Group of type Server
	GroupServer
	// GroupConfig is a Group of type Config
	GroupConfig
	// GroupLogger is a Group of type Logger
	GroupLogger
	// GroupFile is a Group of type File
	GroupFile
	// GroupBlockchain is a Group of type Blockchain
	GroupBlockchain
	// GroupDatabase is a Group of type Database
	GroupDatabase
	// GroupHttp is a Group of type Http
	GroupHttp
	// GroupMicroservice is a Group of type Microservice
	GroupMicroservice
	// GroupMessageCoder is a Group of type MessageCoder
	GroupMessageCoder
	// GroupTime is a Group of type Time
	GroupTime
	// GroupApiTime is a Group of type ApiTime
	GroupApiTime
	// GroupTransport is a Group of type Transport
	GroupTransport
	// GroupCompress is a Group of type Compress
	GroupCompress
	// GroupIO is a Group of type IO
	GroupIO
	// GroupCrypto is a Group of type Crypto
	GroupCrypto
	// GroupQR is a Group of type QR
	GroupQR
	// GroupValidator is a Group of type Validator
	GroupValidator
	// GroupString is a Group of type String
	GroupString
	// GroupUtils is a Group of type Utils
	GroupUtils
	// GroupClient is a Group of type Client
	GroupClient
	// GroupGeneratorEnum is a Group of type GeneratorEnum
	GroupGeneratorEnum
	// GroupRouter is a Group of type Router
	GroupRouter
	// GroupRegistry is a Group of type Registry
	GroupRegistry
	// GroupTools is a Group of type Tools
	GroupTools
	// GroupUnknown is a Group of type Unknown
	GroupUnknown
)

func (Group) MarshalText

func (x Group) MarshalText() ([]byte, *Error)

MarshalText implements the text marshaller method

func (Group) String

func (x Group) String() string

String implements the Stringer interface.

func (Group) UnmarshalText

func (x Group) UnmarshalText(text []byte) (Group, *Error)

UnmarshalText implements the text unmarshaller method

type Subgroup

type Subgroup int32

Subgroup x ENUM( General DiscoveryService BrokerService CircuitBreakerService MetricsService Client Server Selected Serializer Hash QR Version Config Time Validator String Logger File GRPC NET URL Codec Event AVAEnum Unknown )

const (
	// SubgroupGeneral is a Subgroup of type General
	SubgroupGeneral Subgroup = iota
	// SubgroupDiscoveryService is a Subgroup of type DiscoveryService
	SubgroupDiscoveryService
	// SubgroupBrokerService is a Subgroup of type BrokerService
	SubgroupBrokerService
	// SubgroupCircuitBreakerService is a Subgroup of type CircuitBreakerService
	SubgroupCircuitBreakerService
	// SubgroupMetricsService is a Subgroup of type MetricsService
	SubgroupMetricsService
	// SubgroupClient is a Subgroup of type Client
	SubgroupClient
	// SubgroupServer is a Subgroup of type Server
	SubgroupServer
	// SubgroupSelected is a Subgroup of type Selected
	SubgroupSelected
	// SubgroupSerializer is a Subgroup of type Serializer
	SubgroupSerializer
	// SubgroupHash is a Subgroup of type Hash
	SubgroupHash
	// SubgroupQR is a Subgroup of type QR
	SubgroupQR
	// SubgroupVersion is a Subgroup of type Version
	SubgroupVersion
	// SubgroupConfig is a Subgroup of type Config
	SubgroupConfig
	// SubgroupTime is a Subgroup of type Time
	SubgroupTime
	// SubgroupValidator is a Subgroup of type Validator
	SubgroupValidator
	// SubgroupString is a Subgroup of type String
	SubgroupString
	// SubgroupLogger is a Subgroup of type Logger
	SubgroupLogger
	// SubgroupFile is a Subgroup of type File
	SubgroupFile
	// SubgroupGRPC is a Subgroup of type GRPC
	SubgroupGRPC
	// SubgroupNET is a Subgroup of type NET
	SubgroupNET
	// SubgroupURL is a Subgroup of type URL
	SubgroupURL
	// SubgroupCodec is a Subgroup of type Codec
	SubgroupCodec
	// SubgroupEvent is a Subgroup of type Event
	SubgroupEvent
	// SubgroupAVAEnum is a Subgroup of type AVAEnum
	SubgroupAVAEnum
	// SubgroupUnknown is a Subgroup of type Unknown
	SubgroupUnknown
)

func (Subgroup) MarshalText

func (x Subgroup) MarshalText() ([]byte, *Error)

MarshalText implements the text marshaller method

func (Subgroup) String

func (x Subgroup) String() string

String implements the Stringer interface.

func (Subgroup) UnmarshalText

func (x Subgroup) UnmarshalText(text []byte) (Subgroup, *Error)

UnmarshalText implements the text unmarshaller method

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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