You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 19 Next »

基本介绍

GF框架提供了强大、丰富的错误处理能力,由gerror模块实现。

使用方式

import "github.com/gogf/gf/errors/gerror"

接口文档

https://godoc.org/github.com/gogf/gf/errors/gerror

错误创建

1、New/Newf

func New(text string) error
func Newf(format string, args ...interface{}) error

用于创建一个自定义错误信息的error对象,并包含堆栈信息。

2、Wrap/Wrapf

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

用于包裹其他错误error对象,构造成多级的错误信息。

3、NewSkip/NewSkipf

func NewSkip(skip int, text string) error 
func NewSkipf(skip int, format string, args ...interface{}) error

用于创建一个自定义错误信息的error对象,并且忽略部分堆栈信息(按照当前调用方法位置往上忽略)。高级功能,一般开发者很少用得到。

4、错误码NewCode/NewCodef/NewCodeSkip/NewCodeSkipf







Content Menu

  • No labels