From 1718c9c8adf1ef86439ef08dd1f155d6927c3e7a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=99=BD=E8=8C=B6=E6=B8=85=E6=AC=A2?= Date: Sat, 10 May 2025 19:37:27 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96Error=E5=AE=9E=E7=8E=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- exception.go | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/exception.go b/exception.go index a9bbe5a..848b42f 100644 --- a/exception.go +++ b/exception.go @@ -8,6 +8,7 @@ package exception import ( + "encoding/json" "errors" "fmt" "runtime" @@ -28,7 +29,13 @@ type Exception struct { } func (e *Exception) Error() string { - return e.Message() + mapData := map[string]any{ + "code": e.Code(), + "msg": e.Message(), + "data": e.Data(), + } + byteData, _ := json.Marshal(mapData) + return string(byteData) } func (e *Exception) GetStack() string {