浏览代码

空错误新增堆栈信息判定

jys 2 年之前
父节点
当前提交
0c21bf02b2
共有 1 个文件被更改,包括 7 次插入0 次删除
  1. 7 0
      v2alpha/public.go

+ 7 - 0
v2alpha/public.go

@@ -46,6 +46,13 @@ func WithCode[T codeType](err error, businessCode T, options ...Option) error {
 		option(ret)
 	}
 
+	if err == nil {
+		return &withStack{
+			error: ret,
+			stack: callers(),
+		}
+	}
+
 	return ret
 }