Documentation
¶
Index ¶
- func Cause(err error) error
- func Code(err error) agcodes.Coder
- func Current(err error) error
- func Equal(err, target error) bool
- func HasCode(err error, code agcodes.Coder) bool
- func HasError(err, target error) bool
- func HasStack(err error) bool
- func Is(err, target error) bool
- func New(s string) error
- func NewCode(code agcodes.Coder, s ...string) error
- func NewCodeF(code agcodes.Coder, format string, a ...interface{}) error
- func NewF(format string, a ...interface{}) error
- func Stack(err error) string
- func Unwrap(err error) error
- func Wrap(e error, s string) error
- type Error
- type Frame
- type ICause
- type ICode
- type ICurrent
- type IEqual
- type IIs
- type IStack
- type IUnwrap
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Current ¶
Current creates and returns the current level error. It returns nil if current level error is nil.
func Equal ¶
Equal reports whether current error `err` equals to error `target`. Please note that, in default comparison logic for `Error`, the errors are considered the same if both the `code` and `text` of them are the same.
func Is ¶
Is reports whether current error `err` has error `target` in its chaining errors. It is just for implements for stdlib errors.Is from Go version 1.17.
func NewCode ¶
NewCode creates and returns an error that has error code and given text.
Example ¶
package main
import (
"fmt"
"github.com/wond4/go-frame/core/errorx/agcodes"
"github.com/wond4/go-frame/core/errorx/agerrors"
)
func main() {
err := agerrors.NewCode(
//agcodes.New("10000", "", "", "", nil, ""),
agcodes.CodeInvalidParameter,
"My Error")
fmt.Println(err.Error())
fmt.Println(agerrors.Code(err))
}
Output: My Error Public.InvalidParameter:调用服务 [serviceName] 接口 [interfaceName] 参数值 [params] 校验不通过。
func NewCodeF ¶
NewCodeF returns an error that has error code and formats as the given format and args.
func Stack ¶
Stack returns the stack callers as string. It returns the error string directly if the `err` does not support stacks.
Types ¶
type Error ¶
type Error struct {
// contains filtered or unexported fields
}
Error is custom error for additional features.
func (*Error) Current ¶
Current creates and returns the current level error. It returns nil if current level error is nil.
func (*Error) Equal ¶
Equal reports whether current error `err` equals to error `target`. Please note that, in default comparison for `Error`, the errors are considered the same if both the `code` and `text` of them are the same.
func (*Error) Is ¶
Is reports whether current error `err` has error `target` in its chaining errors. It is just for implements for stdlib errors.Is from Go version 1.17.
type Frame ¶
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 ¶
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 ¶
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.