error message
This commit is contained in:
parent
3049ffba1f
commit
80ccd7101d
31
internal/photos/api/errors.go
Normal file
31
internal/photos/api/errors.go
Normal file
@ -0,0 +1,31 @@
|
|||||||
|
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(),
|
||||||
|
})
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user