trace_error

package module
v0.0.0-...-6c6cd3c Latest Latest
Warning

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

Go to latest
Published: May 18, 2024 License: MIT Imports: 3 Imported by: 0

README

trace_error

A traceable error implement in golang

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Err

type Err interface {
	Error() string
	// IsNil() bool
	IsErr() bool

	GetCause() error
	GetCode() string
}

type Error

type Error struct {
	Cause error `json:"cause"`

	CodeInt int    `json:"codeInt"`
	CodeStr string `json:"codeStr"`
	Msg     string `json:"msg"`

	Skip int    `json:"skip"`
	Fn   string `json:"fn"`
	File string `json:"file"`
	Line int    `json:"line"`
}

Don't alter field CodeStr for predefined Error

func NewError

func NewError(cause error, codeInt int, codeStr string, opts ...ErrorOption) (self *Error)

func (*Error) Describe

func (self *Error) Describe() string

func (*Error) Error

func (self *Error) Error() string

func (*Error) GetCause

func (self *Error) GetCause() error

func (*Error) GetCode

func (self *Error) GetCode() string

func (*Error) IntoResponse

func (self *Error) IntoResponse(opts ...ResponseOption) Response

func (*Error) IsErr

func (self *Error) IsErr() bool

func (*Error) IsNil

func (self *Error) IsNil() bool

func (*Error) Retrace

func (self *Error) Retrace() *Error

func (*Error) String

func (self *Error) String() string

func (*Error) Trace

func (self *Error) Trace() string

func (*Error) XCause

func (self *Error) XCause(e error) *Error

func (*Error) XCode

func (self *Error) XCode(codeInt int) *Error

func (*Error) XMsg

func (err *Error) XMsg(msg string) *Error

type ErrorOption

type ErrorOption func(*Error)

type ErrorOption func(*Error) bool

func Msg

func Msg(msg string) ErrorOption

func NoTrace

func NoTrace() ErrorOption

func Skip

func Skip(skip int) ErrorOption

type Response

type Response struct {
	RequestId string `json:"requestId"`
	Code      string `json:"code"`
	Msg       string `json:"msg"`
	Data      any    `json:"data"`
}

func FromError

func FromError(err *Error, opts ...ResponseOption) Response

func NewResponse

func NewResponse(data any, opts ...ResponseOption) Response

func (*Response) XRequestId

func (self *Response) XRequestId(requestId string) *Response

type ResponseOption

type ResponseOption func(*Response)

func RequestId

func RequestId(requestId string) ResponseOption

Directories

Path Synopsis
create your owner predefined errorx.Errorx from trace_error.Error in your project
create your owner predefined errorx.Errorx from trace_error.Error in your project

Jump to

Keyboard shortcuts

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