2022-02-13 18:51:38 +01:00

42 lines
1.1 KiB
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")
// Store
ErrStorePathNotADirectory = errors.New("store path is not a directory")
ErrStoreBadChecksum = errors.New("checksum should be sha1 in hex format")
ErrStoreBadChunkSize = errors.New("part file size should be 1MB max")
ErrStoreWrongPartChecksum = errors.New("part file wrong checksum")
)
func (s *Service) Error(c *gin.Context, code int, err error) {
c.AbortWithStatusJSON(code, gin.H{
"status": "failed",
"error": err.Error(),
})
}