meta

package
v0.2.3 Latest Latest
Warning

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

Go to latest
Published: Apr 19, 2024 License: Apache-2.0 Imports: 3 Imported by: 1

Documentation

Index

Constants

View Source
const CategoryBitOnErrorCode = 24

CategoryBitOnErrorCode is used to shift category on error code

Variables

This section is empty.

Functions

func NewError

func NewError(code ErrCode, msg string, err error) error

NewError creates a new error with error code, message and preceding error

Types

type Category

type Category uint8

Category is the category of dynamicgo modules

const (
	// dynamicgo/json
	JSON Category = 0x01
	// dynamicgo/thrift
	THRIFT Category = 0x02
	// dynamicgo/conv/j2t
	JSON2THRIFT Category = 0x11
	// dynamicgo/conv/t2j
	THRIFT2JSON Category = 0x12
	// dynamicgo/proto
	PROTOBUF Category = 0x03
	// dynamicgo/conv/j2p
	JSON2PROTOBUF Category = 0x13
	// dynamicgo/conv/p2j
	PROTOBUF2JSON Category = 0x14
)

func (Category) String

func (ec Category) String() string

String returns the string representation of Category

type Encoding

type Encoding int

Encoding protocol enum

const (
	// EncodingJSON is json protocol
	EncodingJSON Encoding = iota + 1
	// EncodingThriftBinary is thrift binary protocol
	EncodingThriftBinary
	// EncodingThriftCompact is thrift compact protocol
	EncodingThriftCompact
	// EncodingProtobuf is protobuf protocol
	EncodingProtobuf

	// text encoding, see thrift/binary.go::EncodeText()
	EncodingText
)

func (Encoding) String

func (p Encoding) String() string

String returns the string representation of Encoding

type ErrCode

type ErrCode uint32

ErrCode is the error code of dynamicgo. Usually the left 8 bits are used to represent the category of error, and the right 24 bits are used to represent the behavior of error.

const (
	// ErrUnsupportedType represents unsupported type error
	ErrUnsupportedType ErrCode = 1 + iota
	// ErrStackOverflow represents exceed stack limit error
	ErrStackOverflow
	// ErrRead represents read error
	ErrRead
	// ErrWrite represents write error
	ErrWrite
	// ErrDismatchType represents dismatch type error
	ErrDismatchType
	// ErrConvert represents convert error
	ErrConvert
	// ErrNotFound represents not found error
	ErrNotFound
	// ErrMissRequiredField represents missing required field error
	ErrMissRequiredField
	// ErrUnknownField represents unknown field error
	ErrUnknownField
	// ErrInvalidParam represents invalid parameter error
	ErrInvalidParam
	// ErrNotImplemented represents not implemented error
	ErrNotImplemented
)

Error Behaviors

func NewErrorCode

func NewErrorCode(behavior ErrCode, category Category) ErrCode

NewErrorCode created a new error code with category and behavior

func (ErrCode) Behavior

func (ec ErrCode) Behavior() ErrCode

Behavior returns the behavior of error code

func (ErrCode) Category

func (ec ErrCode) Category() Category

Category returns the category of error code

func (ErrCode) Error

func (ec ErrCode) Error() string

Error implement error interface

func (ErrCode) String

func (ec ErrCode) String() string

String returns the string representation of error code

type Error

type Error struct {
	Code ErrCode
	Msg  string
	Err  error
}

Error is the error concrete type of dynamicgo

func (Error) Error

func (err Error) Error() string

Error return error message, combining category, behavior and message

func (Error) Message

func (err Error) Message() string

Message return current message if has, otherwise return preceding error message

func (Error) Unwrap

func (err Error) Unwrap() error

Unwrap implements errors.Unwrap interface

type MapFieldWay

type MapFieldWay uint8

MapFieldWay is the way to map an given key to field for struct descriptor

const (
	// MapFieldUseAlias means use alias to map key to field
	MapFieldUseAlias MapFieldWay = iota
	// MapFieldUseFieldName means use field name to map key to field
	MapFieldUseFieldName
	// MapFieldUseBoth means use both alias and field name to map key to field
	MapFieldUseBoth
)

type NameCase

type NameCase uint8

NameCase is the case of field name

const (
	// CaseDefault means use the original field name
	CaseDefault NameCase = iota
	// CaseSnake means use snake case
	CaseSnake
	// CaseUpperCamel means use upper camel case
	CaseUpperCamel
	// CaseLowerCamel means use lower camel case
	CaseLowerCamel
)

type ParseFunctionMode

type ParseFunctionMode int8

ParseFunctionMode indicates to parse only response or request for a IDL

const (
	// ParseBoth indicates to parse both request and response for a IDL
	ParseBoth ParseFunctionMode = iota
	// ParseRequestOnly indicates to parse only request for a IDL
	ParseRequestOnly
	// ParseResponseOnly indicates to parse only response for a IDL
	ParseResponseOnly
)

type ParseServiceMode

type ParseServiceMode int8

ParseServiceMode .

const (
	// LastServiceOnly forces the parser to parse only the last service definition.
	LastServiceOnly ParseServiceMode = iota

	// FirstServiceOnly forces the parser to parse only the first service definition.
	FirstServiceOnly

	// CombineServices forces the parser to combine methods of all service definitions.
	// Note that method names of the service definitions can not be duplicate.
	CombineServices
)

Jump to

Keyboard shortcuts

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