Merge branch 'main' of https://git.apinb.com/bsm-sdk/core
This commit is contained in:
commit
d4b7e7e9e6
|
@ -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
|
||||||
|
|
Loading…
Reference in New Issue