增加是否制定错误码判断

This commit is contained in:
zhangdeman committed 2023-09-28 00:40:57 +08:00
1 parent b4732e360b
commit 8c8c730a3b
2 files changed
+11

No files matched your search

+2
View File
@@ -29,4 +29,6 @@ type IException interface {
GetHttpCode() int
// ToError 转换为内置error类型
ToError() error
// IsCode 是否为指定code
IsCode(code interface{}) bool
}
+9
View File
@@ -59,6 +59,15 @@ func (e *Exception) ToError() error {
return errors.New(e.Error())
}
// IsCode 判断是否为指定错误码
//
// Author : go_developer@163.com<白茶清欢>
//
// Date : 00:39 2023/9/28
func (e *Exception) IsCode(inputCode interface{}) bool {
return fmt.Sprintf("%v", inputCode) == fmt.Sprintf("%v", e.GetCode())
}
// NewWithCode 仅使用错误码实例化异常
//
// Author : go_developer@163.com<白茶清欢>
Reference in new issue
Block a user
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.