增加ToError方法

This commit is contained in:
zhangdeman001
2023-05-11 18:20:56 +08:00
parent 0679ce5092
commit 2bc6061e1c
4 changed files with 29 additions and 39 deletions

View File

@ -41,6 +41,13 @@ func (e *Exception) GetHttpCode() int {
return e.httpCode
}
func (e *Exception) ToError() error {
if nil == e {
return nil
}
return errors.New(e.Error())
}
// NewWithCode 仅使用错误码实例化异常
//
// Author : go_developer@163.com<白茶清欢>