36 lines
775 B
Go
36 lines
775 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")
|
|
|
|
// Album
|
|
ErrAlbumDontExists = errors.New("album doesn't exists")
|
|
)
|
|
|
|
func (s *Service) Error(c *gin.Context, code int, err error) {
|
|
c.AbortWithStatusJSON(code, gin.H{
|
|
"status": "failed",
|
|
"error": err.Error(),
|
|
})
|
|
}
|