chore: common err resp log
This commit is contained in:
@ -1,15 +1,20 @@
|
||||
package common
|
||||
|
||||
import (
|
||||
"github.com/alist-org/alist/v3/cmd/args"
|
||||
"github.com/gin-gonic/gin"
|
||||
log "github.com/sirupsen/logrus"
|
||||
)
|
||||
|
||||
// ErrorResp is used to return error response
|
||||
// @param nl: if true, don't log error
|
||||
func ErrorResp(c *gin.Context, err error, code int, nl ...bool) {
|
||||
if len(nl) == 0 || !nl[0] {
|
||||
log.Errorf("%+v", err)
|
||||
// @param l: if true, log error
|
||||
func ErrorResp(c *gin.Context, err error, code int, l ...bool) {
|
||||
if len(l) > 0 && l[0] {
|
||||
if args.Debug || args.Dev {
|
||||
log.Errorf("%+v", err)
|
||||
} else {
|
||||
log.Errorf("%v", err)
|
||||
}
|
||||
}
|
||||
c.JSON(200, Resp{
|
||||
Code: code,
|
||||
|
Reference in New Issue
Block a user