diff --git a/.idea/workspace.xml b/.idea/workspace.xml
index 84ecd7c..ed3c81b 100644
--- a/.idea/workspace.xml
+++ b/.idea/workspace.xml
@@ -7,6 +7,7 @@
+
@@ -20,7 +21,7 @@
-
+
@@ -35,46 +36,27 @@
+
+
+
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
@@ -89,9 +71,8 @@
-
- true
+ true
\ No newline at end of file
diff --git a/abstrace.go b/abstrace.go
index 802d85f..124b513 100644
--- a/abstrace.go
+++ b/abstrace.go
@@ -23,4 +23,6 @@ type IException interface {
GetData() interface{}
// GetHttpCode *获取当前异常要返回的http状态码, 不设置则 默认 200
GetHttpCode() int
+ // ToError 转换为内置error类型
+ ToError() error
}
diff --git a/exception.go b/exception.go
index aa4a8b1..85ddd71 100644
--- a/exception.go
+++ b/exception.go
@@ -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<白茶清欢>
diff --git a/go.mod b/go.mod
index cb8e24a..7847a45 100644
--- a/go.mod
+++ b/go.mod
@@ -1,3 +1,3 @@
module git.zhangdeman.cn/zhangdeman/exception
-go 1.17
+go 1.20