优化Error实现
This commit is contained in:
parent
255d79affb
commit
1718c9c8ad
@ -8,6 +8,7 @@
|
|||||||
package exception
|
package exception
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"encoding/json"
|
||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
"runtime"
|
"runtime"
|
||||||
@ -28,7 +29,13 @@ type Exception struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (e *Exception) Error() string {
|
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 {
|
func (e *Exception) GetStack() string {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user