Compare commits
5 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| d4b7e7e9e6 | |||
| 98ee26f215 | |||
| 0218dfd02e | |||
|
|
629ec74be6 | ||
| a128eb8461 |
@@ -41,10 +41,6 @@ func New(srvKey string, cfg any) {
|
||||
log.Fatalln("ERROR: Service Not Nil", cfp)
|
||||
}
|
||||
|
||||
if !strings.Contains(string(yamlFile), "Port:") {
|
||||
log.Fatalln("ERROR: Port Not Nil", cfp)
|
||||
}
|
||||
|
||||
// 解析YAML
|
||||
err = yaml.Unmarshal(yamlFile, cfg)
|
||||
if err != nil {
|
||||
@@ -55,7 +51,7 @@ func New(srvKey string, cfg any) {
|
||||
func NotNil(values ...string) {
|
||||
for _, value := range values {
|
||||
if strings.TrimSpace(value) == "" {
|
||||
log.Fatalln("ERROR:Must config not nil")
|
||||
log.Fatalln("ERROR:Must config key not nil")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -10,10 +10,12 @@ var (
|
||||
ErrHeaderRequestId = NewError(101, "Header Request-Id Not Found")
|
||||
ErrHeaderAuthorization = NewError(102, "Header Authorization Not Found")
|
||||
ErrHeaderSecretKey = NewError(103, "Header Secret-Key Not Found")
|
||||
ErrHeaderMustParams = NewError(104, "Header Must Params")
|
||||
)
|
||||
|
||||
// standard error code ,start:110
|
||||
var (
|
||||
ErrEmpty = NewError(110, "Data Is Empty")
|
||||
ErrRequestParse = NewError(111, "Request Parse Fail")
|
||||
ErrRequestMust = NewError(112, "Request Params Required")
|
||||
ErrPermission = NewError(113, "Permission Denied")
|
||||
|
||||
@@ -16,6 +16,7 @@ type Reply struct {
|
||||
func (reply *Reply) Success(ctx *gin.Context, data any) {
|
||||
reply.Code = 200
|
||||
reply.Data = data
|
||||
reply.Msg = ""
|
||||
if data == nil {
|
||||
reply.Data = ""
|
||||
}
|
||||
@@ -23,12 +24,12 @@ func (reply *Reply) Success(ctx *gin.Context, data any) {
|
||||
}
|
||||
func (reply *Reply) Error(ctx *gin.Context, err error) {
|
||||
reply.Code = 500
|
||||
reply.Data = ""
|
||||
// Status code defaults to 500
|
||||
e, ok := status.FromError(err)
|
||||
if ok {
|
||||
reply.Code = int(e.Code())
|
||||
}
|
||||
|
||||
reply.Msg = e.Message()
|
||||
|
||||
// Send error
|
||||
|
||||
Reference in New Issue
Block a user