2022-02-05 11:23:28 +01:00

32 lines
684 B
Go

package api
import (
"errors"
"github.com/gin-gonic/gin"
)
var (
// Session
ErrSessionNotFound = errors.New("session not found")
ErrSessionInvalid = errors.New("session invalid")
ErrTokenMissing = errors.New("token missing")
// Request
ErrReqMissingBody = errors.New("missing body")
ErrReqNotFound = errors.New("this route doesn't exists")
// Account
ErrAccountExists = errors.New("account exists")
ErrAccountAuth = errors.New("login or password incorrect")
// Panic
ErrUnexpected = errors.New("an unexpected error occur")
)
func (s *Service) Error(c *gin.Context, code int, err error) {
c.AbortWithStatusJSON(code, gin.H{
"error": err.Error(),
})
}