Compare commits
1 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
629ec74be6 |
@@ -16,6 +16,7 @@ type Reply struct {
|
|||||||
func (reply *Reply) Success(ctx *gin.Context, data any) {
|
func (reply *Reply) Success(ctx *gin.Context, data any) {
|
||||||
reply.Code = 200
|
reply.Code = 200
|
||||||
reply.Data = data
|
reply.Data = data
|
||||||
|
reply.Msg = ""
|
||||||
if data == nil {
|
if data == nil {
|
||||||
reply.Data = ""
|
reply.Data = ""
|
||||||
}
|
}
|
||||||
@@ -23,12 +24,12 @@ func (reply *Reply) Success(ctx *gin.Context, data any) {
|
|||||||
}
|
}
|
||||||
func (reply *Reply) Error(ctx *gin.Context, err error) {
|
func (reply *Reply) Error(ctx *gin.Context, err error) {
|
||||||
reply.Code = 500
|
reply.Code = 500
|
||||||
|
reply.Data = ""
|
||||||
// Status code defaults to 500
|
// Status code defaults to 500
|
||||||
e, ok := status.FromError(err)
|
e, ok := status.FromError(err)
|
||||||
if ok {
|
if ok {
|
||||||
reply.Code = int(e.Code())
|
reply.Code = int(e.Code())
|
||||||
}
|
}
|
||||||
|
|
||||||
reply.Msg = e.Message()
|
reply.Msg = e.Message()
|
||||||
|
|
||||||
// Send error
|
// Send error
|
||||||
|
|||||||
Reference in New Issue
Block a user