19 lines
372 B
Go
19 lines
372 B
Go
|
package httputil
|
||
|
|
||
|
import "github.com/gin-gonic/gin"
|
||
|
|
||
|
// NewError example
|
||
|
func NewError(ctx *gin.Context, status int, err error) {
|
||
|
er := HTTPError{
|
||
|
Code: status,
|
||
|
Message: err.Error(),
|
||
|
}
|
||
|
ctx.JSON(status, er)
|
||
|
}
|
||
|
|
||
|
// HTTPError example
|
||
|
type HTTPError struct {
|
||
|
Code int `json:"code" example:"400"`
|
||
|
Message string `json:"message" example:"status bad request"`
|
||
|
}
|