structerror

package module
v0.0.0-...-d52b0c0 Latest Latest
Warning

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

Go to latest
Published: Jan 15, 2021 License: Apache-2.0 Imports: 2 Imported by: 0

README

structerror

A error with code and message.

  • easy to compare with the code.
  • output as struct string like json.
// StructError interface
type StructError interface {
	error
	ErrorCode() int
}

// StructJsonError interface
type StructJsonError interface {
	StructError
	JSON() (string, error)
}

CodeError

An impletement of struct error.

type CodeError struct {
	Code   int
	Status string
	Msg    string
	Causes []error
}

Documentation

Index

Constants

View Source
const (
	// CodeUnknown is unknown error code
	CodeUnknown = 1099
	// StatusUnknown is unknown error code status
	StatusUnknown = "Unknown"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type CodeError

type CodeError struct {
	Code   int
	Status string
	Msg    string
	Causes []error
}

CodeError is error with code

func (CodeError) Error

func (ce CodeError) Error() string

Error impletment Error interface

func (CodeError) ErrorCode

func (ce CodeError) ErrorCode() int

Code impletment Code interface

func (CodeError) JSON

func (ce CodeError) JSON() (string, error)

JSON impletment StructError interface

func (CodeError) MarshalJSON

func (ce CodeError) MarshalJSON() ([]byte, error)

MarshalJSON impletement json.Marshal interface

type CodeErrorFactory

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

CodeErrorFactory is to generate new CodeError

func NewCodeErrorFactory

func NewCodeErrorFactory(codeMap map[int]string) CodeErrorFactory

NewCodeErrorFactory impletment a CodeErrorFactory

func (CodeErrorFactory) Error

func (f CodeErrorFactory) Error(code int, msg string, causes ...error) CodeError

NewError generate a new CodeError

type StructError

type StructError interface {
	error
	ErrorCode() int
}

StructError interface

type StructJsonError

type StructJsonError interface {
	StructError
	JSON() (string, error)
}

StructJsonError interface

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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