feat: user & article: dev complete
This commit is contained in:
33
handler/errors.go
Normal file
33
handler/errors.go
Normal file
@@ -0,0 +1,33 @@
|
||||
package handler
|
||||
|
||||
import (
|
||||
"github.com/gin-gonic/gin"
|
||||
"nCovTrack-Backend/utils"
|
||||
"net/http"
|
||||
)
|
||||
|
||||
// This file is define some business error
|
||||
|
||||
const (
|
||||
BAD_REQUEST = "Bad Request"
|
||||
DATA_NOT_FOUND = "Data not Found"
|
||||
STATUS_DATA_NOT_FOUND = 210
|
||||
)
|
||||
|
||||
func RequestError(c *gin.Context, code int, data interface{}) {
|
||||
utils.Error(c, http.StatusBadRequest, code, BAD_REQUEST, data)
|
||||
}
|
||||
|
||||
func RequestErr(c *gin.Context, data interface{}) {
|
||||
RequestError(c, http.StatusBadRequest, data)
|
||||
}
|
||||
func ServerError(c *gin.Context, code int, msg interface{}) {
|
||||
utils.Err(c, http.StatusInternalServerError, code, msg)
|
||||
}
|
||||
|
||||
func ServerErr(c *gin.Context, msg interface{}) {
|
||||
ServerError(c, http.StatusInternalServerError, msg)
|
||||
}
|
||||
func DataNotFound(c *gin.Context, data interface{}) {
|
||||
utils.Success(c, http.StatusOK, STATUS_DATA_NOT_FOUND, DATA_NOT_FOUND, data)
|
||||
}
|
||||
Reference in New Issue
Block a user