升级exception, 简化逻辑 #1
@ -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 {
 | 
			
		||||
 | 
			
		||||
		Reference in New Issue
	
	Block a user