优化Error实现

This commit is contained in:
白茶清欢 2025-05-10 19:37:27 +08:00
parent 255d79affb
commit 1718c9c8ad

View File

@ -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 {