errors

package
v0.0.0-...-a10a6d9 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 29, 2025 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetPlayerIDFromAuthMessage

func GetPlayerIDFromAuthMessage(msg *message.Message) (string, error)

GetPlayerID returns the player ID for successful authentication This should be called after successful authentication to get the player ID for session management

func GetUserFriendlyErrorMessage

func GetUserFriendlyErrorMessage(err error) string

GetUserFriendlyErrorMessage converts technical errors to user-friendly messages

func LogError

func LogError(err error, context map[string]interface{})

LogError logs errors with appropriate context

Types

type AuthResponse

type AuthResponse struct {
	Success bool   `json:"success"`
	Message string `json:"message,omitempty"`
	Error   string `json:"error,omitempty"`
}

AuthResponse represents the structure of authentication responses

type ErrorRecoverySystem

type ErrorRecoverySystem struct {
	// contains filtered or unexported fields
}

ErrorRecoverySystem handles error recovery for the Wumpus Hunt game

func NewErrorRecoverySystem

func NewErrorRecoverySystem(storageManager *storage.Manager, gameStateManager *game.StateManager) *ErrorRecoverySystem

NewErrorRecoverySystem creates a new error recovery system

func (*ErrorRecoverySystem) RecoverFromInterruptedGame

func (ers *ErrorRecoverySystem) RecoverFromInterruptedGame(player *storage.Player) *WumpusError

RecoverFromInterruptedGame handles recovery when a player's game was interrupted

func (*ErrorRecoverySystem) RecoverFromPropertiesCorruption

func (ers *ErrorRecoverySystem) RecoverFromPropertiesCorruption(player *storage.Player, propertyKey string) *WumpusError

RecoverFromPropertiesCorruption attempts to recover from corrupted player properties

func (*ErrorRecoverySystem) SafePropertyAccess

func (ers *ErrorRecoverySystem) SafePropertyAccess(player *storage.Player, propertyKey string, defaultValue interface{}) (interface{}, *WumpusError)

SafePropertyAccess provides safe access to player properties with automatic recovery

func (*ErrorRecoverySystem) ValidatePlayerIntegrity

func (ers *ErrorRecoverySystem) ValidatePlayerIntegrity(player *storage.Player) []*WumpusError

ValidatePlayerIntegrity performs comprehensive validation of player data

type ErrorType

type ErrorType int

ErrorType represents different categories of errors

const (
	ErrorTypePropertiesCorruption ErrorType = iota
	ErrorTypeAuthenticationFailure
	ErrorTypeGameStateCorruption
	ErrorTypeWorldCorruption
	ErrorTypeInstanceCorruption
	ErrorTypeNetworkFailure
	ErrorTypeUserInput
	ErrorTypeSystem
)

type RecoveryAction

type RecoveryAction int

RecoveryAction represents actions that can be taken to recover from errors

const (
	RecoveryActionNone RecoveryAction = iota
	RecoveryActionResetProperties
	RecoveryActionRespawnPlayer
	RecoveryActionReturnToInn
	RecoveryActionCreateNewInstance
	RecoveryActionFullReset
	RecoveryActionKickPlayer
)

type SafeAuthHandler

type SafeAuthHandler struct {
	// contains filtered or unexported fields
}

SafeAuthHandler provides authentication handling with comprehensive error recovery

func NewSafeAuthHandler

func NewSafeAuthHandler(safeAuth *SafeAuthOperations, storageMgr *storage.Manager) *SafeAuthHandler

NewSafeAuthHandler creates a new safe authentication handler

func (*SafeAuthHandler) HandleAuthentication

func (h *SafeAuthHandler) HandleAuthentication(s *server.ConnServer, clientID string, msg *message.Message)

HandleAuthentication handles player authentication with comprehensive error recovery

type SafeAuthOperations

type SafeAuthOperations struct {
	// contains filtered or unexported fields
}

SafeAuthOperations provides authentication operations with built-in error recovery

func NewSafeAuthOperations

func NewSafeAuthOperations(recoverySystem *ErrorRecoverySystem) *SafeAuthOperations

NewSafeAuthOperations creates a new safe authentication operations handler

func (*SafeAuthOperations) RecoverPlayerSession

func (ops *SafeAuthOperations) RecoverPlayerSession(player *storage.Player) []*WumpusError

RecoverPlayerSession attempts to recover a player's session

func (*SafeAuthOperations) SafeGetWumpusAuth

func (ops *SafeAuthOperations) SafeGetWumpusAuth(player *storage.Player) (*auth.WumpusAuth, *WumpusError)

SafeGetWumpusAuth gets authentication data with error recovery

func (*SafeAuthOperations) SafeGetWumpusState

func (ops *SafeAuthOperations) SafeGetWumpusState(player *storage.Player) (auth.WumpusState, *WumpusError)

SafeGetWumpusState gets player state with error recovery

func (*SafeAuthOperations) SafeGetWumpusStats

func (ops *SafeAuthOperations) SafeGetWumpusStats(player *storage.Player) (auth.WumpusStats, *WumpusError)

SafeGetWumpusStats gets player stats with error recovery

func (*SafeAuthOperations) SafeIsPlayerAuthenticated

func (ops *SafeAuthOperations) SafeIsPlayerAuthenticated(player *storage.Player) (bool, *WumpusError)

SafeIsPlayerAuthenticated checks if player is authenticated with error recovery

func (*SafeAuthOperations) SafeSetPlayerPassword

func (ops *SafeAuthOperations) SafeSetPlayerPassword(player *storage.Player, password string) *WumpusError

SafeSetPlayerPassword sets a player password with error recovery

func (*SafeAuthOperations) SafeUpdateWumpusState

func (ops *SafeAuthOperations) SafeUpdateWumpusState(player *storage.Player, state auth.WumpusState) *WumpusError

SafeUpdateWumpusState updates player state with validation

func (*SafeAuthOperations) SafeUpdateWumpusStats

func (ops *SafeAuthOperations) SafeUpdateWumpusStats(player *storage.Player, stats auth.WumpusStats) *WumpusError

SafeUpdateWumpusStats updates player stats with validation

func (*SafeAuthOperations) SafeValidatePlayerPassword

func (ops *SafeAuthOperations) SafeValidatePlayerPassword(player *storage.Player, password string) (bool, *WumpusError)

SafeValidatePlayerPassword validates a player password with error recovery

type WumpusError

type WumpusError struct {
	Type            ErrorType
	Message         string
	UserMessage     string
	Cause           error
	RecoveryActions []RecoveryAction
	PlayerID        string
	InstanceID      string
	Timestamp       time.Time
	Recoverable     bool
}

WumpusError represents an error with recovery information

func NewWumpusError

func NewWumpusError(errType ErrorType, message, userMessage string, cause error) *WumpusError

NewWumpusError creates a new WumpusError

func (*WumpusError) Error

func (e *WumpusError) Error() string

Error implements the error interface

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL