xerrors

package
v0.12.2 Latest Latest
Warning

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

Go to latest
Published: Mar 13, 2025 License: MIT Imports: 7 Imported by: 2

Documentation

Index

Constants

View Source
const (
	ModuleDefault = "default"
	ModuleProto   = "protogen"
	ModuleConf    = "confgen"
)
View Source
const (
	// The String method processing logic of Desc is dependent on this key's corresponding value.
	// module: default, proto, conf.
	KeyModule = "Module"

	KeyIndir            = "Indir"            // input dir
	KeySubdir           = "Subdir"           // input subdir
	KeyOutdir           = "Outdir"           // output dir
	KeyBookName         = "BookName"         // workbook name
	KeyPrimaryBookName  = "PrimaryBookName"  // primary workbook name
	KeySheetName        = "SheetName"        // worksheet name
	KeyPrimarySheetName = "PrimarySheetName" // primary worksheet name
	KeyNameCellPos      = "NameCellPos"      // name cell position
	KeyNameCell         = "NameCell"         // name cell value
	KeyTrimmedNameCell  = "TrimmedNameCell"  // trimmed name cell value
	KeyTypeCellPos      = "TypeCellPos"      // type cell position
	KeyTypeCell         = "TypeCell"         // type cell value
	KeyDataCellPos      = "DataCellPos"      // data cell position
	KeyDataCell         = "DataCell"         // data data value

	KeyPBMessage   = "PBMessage"   // protobuf message name
	KeyPBFieldName = "PBFieldName" // protobuf message field name
	KeyPBFieldType = "PBFieldType" // protobuf message field type
	KeyPBFieldOpts = "PBFieldOpts" // protobuf message field options (extensions)
	KeyColumnName  = "ColumnName"  // column name

	KeyReason = "Reason" // error

)

desc keys for bookkeeping

Variables

This section is empty.

Functions

func Cause added in v0.12.0

func Cause(err error) error

func Code added in v0.12.0

func Code(err error) int

Code returns the code of top-level error.

func E0001

func E0001(sheetName, bookName string) error

E0001: sheet not found in book.

func E0002 added in v0.11.0

func E0002(filename, messageName, errstr string, lines string) error

E0002: cannot unmarshal file content to given proto.Message.

func E1000 added in v0.11.0

func E1000(name, positon1, positon2 string) error

E1000: column name conflicts in name row.

func E2000 added in v0.11.0

func E2000(typ, value string, min, max any) error

E2000: integer overflow.

func E2001

func E2001(refer string, messageName string) error

E2001: field prop "refer" not configured correctly.

func E2002

func E2002(value string, refer string) error

E2002: field value not in referred space.

func E2003

func E2003(value string, sequence int64) error

E2002: illegal sequence number.

func E2004

func E2004(value any, vrange string) error

E2004: value is out of range.

func E2005

func E2005(key any) error

E2005: map key is not unique.

func E2006

func E2006(value, enumName any) error

E2006: enum value not defined in enum type.

func E2007

func E2007(value, err any) error

E2007: invalid datetime format.

func E2008

func E2008(value, err any) error

E2008: invalid duration format.

func E2009 added in v0.10.7

func E2009(key, fieldName any) error

E2009: duplicate key.

func E2010 added in v0.10.7

func E2010(typeValue, fieldNumber any) error

E2010: union type and value field mismatch.

func E2011 added in v0.11.0

func E2011() error

E2011: field presence required but cell not filled.

func E2012 added in v0.11.0

func E2012(fieldType, value any, err error) error

E2012: invalid syntax of numerical type.

func E2013 added in v0.11.0

func E2013(value any, err error) error

E2013: invalid syntax of boolean type.

func E2014 added in v0.11.0

func E2014(column string) error

E2014: sheet column not found.

func E2015 added in v0.11.0

func E2015(column, bookName, sheetName string) error

E2015: referred sheet column not found.

func E2016 added in v0.11.0

func E2016(firstNonePresentIndex, nextPresentIndex int) error

E2016: list elements are not present continuously.

func E2017 added in v0.11.0

func E2017(mapType string) error

E2017: map contains multiple empty keys.

func E2018 added in v0.11.0

func E2018(keyName string) error

E2018: map key not exist.

func E2019 added in v0.12.0

func E2019(value string, err error) error

E2019: invalid fraction pattern.

func E2020 added in v0.12.0

func E2020(value string, err error) error

E2020: invalid comparator pattern.

func E2021 added in v0.12.0

func E2021(enumType, enumValue1, enumValue2, alias any) error

E2021: duplicate enum value alias.

func E3000 added in v0.11.0

func E3000(sheetSpecifier, pattern string) error

E3000: no workbook file found about sheet specifier.

func E3001 added in v0.11.0

func E3001(sheetName, bookName string) error

E3001: no worksheet found in workbook.

func ErrorKV

func ErrorKV(msg string, keysAndValues ...any) error

ErrorKV returns an error with the supplied message and the key-value pairs as `[|key: value]...` string. ErrorKV also records the stack trace at the point it was called.

func Errorf

func Errorf(format string, args ...interface{}) error

Errorf formats according to a format specifier and returns the string as a value that satisfies error. Errorf also records the code and stack trace at the point it was called. func Errorf(code int, format string, args ...interface{}) error {

func Is added in v0.12.0

func Is(err error, code int) bool

Is reports whether any error in err's tree matches code.

func New added in v0.12.0

func New(code int) error

New returns an error with the supplied code and message. New also records the stack trace at the point it was called

func NewStackless added in v0.12.0

func NewStackless(code int) error

NewStackless returns an error without caller stack.

func WithCode added in v0.12.0

func WithCode(err error, code int) error

WithCode wraps error with a code.

func WithCodef added in v0.12.0

func WithCodef(err error, code int, format string, args ...interface{}) error

WithCodef wraps error with a code and formated message.

func Wrap added in v0.12.0

func Wrap(err error) error

Wrap annotates err with a stack trace at the point Wrap was called. If err is nil, Wrap returns nil.

func WrapKV

func WrapKV(err error, keysAndValues ...any) error

WrapKV formats the key-value pairs as `[|key: value]...` string and returns the string as a value that satisfies error. WrapKV also records the stack trace at the point it was called.

func Wrapf added in v0.12.0

func Wrapf(err error, format string, args ...interface{}) error

Wrapf returns an error annotating err with a stack trace at the point Wrapf is called, and the format specifier. If err is nil, Wrapf returns nil.

Types

type Desc

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

func NewDesc

func NewDesc(err error) *Desc

func (*Desc) DebugString

func (d *Desc) DebugString() string

func (*Desc) ErrCode added in v0.10.7

func (d *Desc) ErrCode() string

func (*Desc) GetValue added in v0.11.0

func (d *Desc) GetValue(key string) any

func (*Desc) String

func (d *Desc) String() string

String render description in specified language.

type Error added in v0.12.0

type Error struct {
	Code int
	Desc string
}

func (*Error) Error added in v0.12.0

func (e *Error) Error() string

func (*Error) Is added in v0.12.0

func (e *Error) Is(target error) bool

type Frame added in v0.12.0

type Frame uintptr

Frame represents a program counter inside a stack frame. For historical reasons if Frame is interpreted as a uintptr its value represents the program counter + 1.

func (Frame) Format added in v0.12.0

func (f Frame) Format(s fmt.State, verb rune)

Format formats the frame according to the fmt.Formatter interface.

%s    source file
%d    source line
%n    function name
%v    equivalent to %s:%d

Format accepts flags that alter the printing of some verbs, as follows:

%+s   function name and path of source file relative to the compile time
      GOPATH separated by \n\t (<funcname>\n\t<path>)
%+v   equivalent to %+s:%d

func (Frame) MarshalText added in v0.12.0

func (f Frame) MarshalText() ([]byte, error)

MarshalText formats a stacktrace Frame as a text string. The output is the same as that of fmt.Sprintf("%+v", f), but without newlines or tabs.

type StackTrace added in v0.12.0

type StackTrace []Frame

StackTrace is stack of Frames from innermost (newest) to outermost (oldest).

func (StackTrace) Format added in v0.12.0

func (st StackTrace) Format(s fmt.State, verb rune)

Format formats the stack of Frames according to the fmt.Formatter interface.

%s	lists source files for each Frame in the stack
%v	lists the source file and line number for each Frame in the stack

Format accepts flags that alter the printing of some verbs, as follows:

%+v   Prints filename, function, and line number for each Frame in the stack.

Jump to

Keyboard shortcuts

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