feat: backend service
This commit is contained in:
@@ -0,0 +1,54 @@
|
||||
package lobby
|
||||
|
||||
import "errors"
|
||||
|
||||
// Sentinel errors surface common rejection reasons across the lobby
|
||||
// package. Handlers map them to HTTP envelopes through `respondLobbyError`
|
||||
// in `internal/server/handlers_user_lobby_helpers.go`.
|
||||
//
|
||||
// Adding a new sentinel here is a deliberate API change: it appears in the
|
||||
// handler error map and may surface as a new wire `code` value. Reuse the
|
||||
// existing set when the behaviour overlaps.
|
||||
var (
|
||||
// ErrInvalidInput reports request-level validation failures (empty
|
||||
// fields, malformed cron expressions, unknown enum values, race-name
|
||||
// policy rejections). Maps to 400 invalid_request.
|
||||
ErrInvalidInput = errors.New("lobby: invalid input")
|
||||
|
||||
// ErrNotFound reports that the requested record (game, application,
|
||||
// invite, membership, race name) does not exist or is not visible to
|
||||
// the caller. Maps to 404 not_found.
|
||||
ErrNotFound = errors.New("lobby: not found")
|
||||
|
||||
// ErrForbidden reports that the caller is authenticated but not
|
||||
// authorised for the requested action — most commonly "not the owner
|
||||
// of this private game". Maps to 403 forbidden.
|
||||
ErrForbidden = errors.New("lobby: forbidden")
|
||||
|
||||
// ErrConflict reports that the requested action conflicts with the
|
||||
// current persisted state (illegal status transition, duplicate
|
||||
// application, race-name canonical taken, invite already redeemed).
|
||||
// Maps to 409 conflict.
|
||||
ErrConflict = errors.New("lobby: conflict")
|
||||
|
||||
// ErrInvalidStatus reports a state-machine transition rejected by the
|
||||
// game/application/invite/membership status. Treated as ErrConflict
|
||||
// at the wire boundary; carried as a separate sentinel so transition
|
||||
// callers can branch on it without parsing the wrapped message.
|
||||
ErrInvalidStatus = errors.New("lobby: invalid status transition")
|
||||
|
||||
// ErrRaceNameTaken reports that a race-name canonical key is already
|
||||
// claimed by a different user (registered, reserved, or
|
||||
// pending_registration). Treated as ErrConflict at the wire boundary.
|
||||
ErrRaceNameTaken = errors.New("lobby: race name is taken")
|
||||
|
||||
// ErrEntitlementExceeded reports that the caller already holds the
|
||||
// maximum number of registered race names allowed by their tier.
|
||||
// Treated as ErrConflict at the wire boundary.
|
||||
ErrEntitlementExceeded = errors.New("lobby: entitlement quota exceeded")
|
||||
|
||||
// ErrPendingExpired reports that the pending_registration window
|
||||
// passed before the user attempted to promote it to registered.
|
||||
// Treated as ErrConflict at the wire boundary.
|
||||
ErrPendingExpired = errors.New("lobby: pending registration expired")
|
||||
)
|
||||
Reference in New Issue
Block a user