Files
go-nkode/core/constants.go
2024-10-14 13:29:05 -05:00

63 lines
3.3 KiB
Go

package core
import (
"errors"
"net/http"
)
var (
ErrInvalidNKodeLength = errors.New("invalid nKode length")
ErrInvalidNKodeIdx = errors.New("invalid passcode attribute index")
ErrTooFewDistinctSet = errors.New("too few distinct sets")
ErrTooFewDistinctAttributes = errors.New("too few distinct attributes")
ErrEmailAlreadySent = errors.New("email already sent")
ErrClaimExpOrNil = errors.New("claim expired or nil")
ErrInvalidJwt = errors.New("invalid jwt")
ErrInvalidKeypadDimensions = errors.New("keypad dimensions out of range")
ErrUserAlreadyExists = errors.New("user already exists")
ErrSignupSessionDNE = errors.New("signup session does not exist")
ErrUserForCustomerDNE = errors.New("user for customer does not exist")
ErrRefreshTokenInvalid = errors.New("refresh token invalid")
ErrCustomerDne = errors.New("customer dne")
ErrSvgDne = errors.New("svg dne")
ErrStoppingDatabase = errors.New("stopping database")
ErrSqliteTx = errors.New("sqlite begin, exec, query, or commit error. see logs")
ErrEmptySvgTable = errors.New("empty svg_icon table")
ErrKeyIndexOutOfRange = errors.New("one or more keys is out of range")
ErrAttributeIndexOutOfRange = errors.New("attribute index out of range")
ErrInternalValidKeyEntry = errors.New("internal validation error")
ErrUserMaskTooLong = errors.New("user mask length exceeds max nkode length")
ErrInterfaceNotDispersible = errors.New("interface is not dispersible")
ErrIncompleteUserSignupSession = errors.New("incomplete user signup session")
ErrSetConfirmSignupMismatch = errors.New("set and confirm nkode are not the same")
ErrKeypadIsNotDispersible = errors.New("keypad is not dispersible")
)
var HttpErrMap = map[error]int{
ErrInvalidNKodeLength: http.StatusBadRequest,
ErrInvalidNKodeIdx: http.StatusBadRequest,
ErrTooFewDistinctSet: http.StatusBadRequest,
ErrTooFewDistinctAttributes: http.StatusBadRequest,
ErrEmailAlreadySent: http.StatusBadRequest,
ErrClaimExpOrNil: http.StatusForbidden,
ErrInvalidJwt: http.StatusForbidden,
ErrInvalidKeypadDimensions: http.StatusBadRequest,
ErrUserAlreadyExists: http.StatusBadRequest,
ErrSignupSessionDNE: http.StatusBadRequest,
ErrUserForCustomerDNE: http.StatusBadRequest,
ErrRefreshTokenInvalid: http.StatusForbidden,
ErrCustomerDne: http.StatusBadRequest,
ErrSvgDne: http.StatusBadRequest,
ErrStoppingDatabase: http.StatusInternalServerError,
ErrSqliteTx: http.StatusInternalServerError,
ErrEmptySvgTable: http.StatusInternalServerError,
ErrKeyIndexOutOfRange: http.StatusBadRequest,
ErrAttributeIndexOutOfRange: http.StatusInternalServerError,
ErrInternalValidKeyEntry: http.StatusInternalServerError,
ErrUserMaskTooLong: http.StatusInternalServerError,
ErrInterfaceNotDispersible: http.StatusInternalServerError,
ErrIncompleteUserSignupSession: http.StatusBadRequest,
ErrSetConfirmSignupMismatch: http.StatusBadRequest,
ErrKeypadIsNotDispersible: http.StatusInternalServerError,
}