Package-level declarations

Overview

Domain-specific exceptions that signal invalid operations or corrupted persisted files (for example: malformed board or piece entries). These exceptions are thrown by the core logic or by the serializers when encountering invalid data.

Exception Types

  • ReversiException — Base exception for all Reversi-specific errors

  • ErrorType — Enum categorizing error severity (INFO, WARNING, ERROR, FATAL)

  • InvalidPlayException — Thrown when attempting to play an invalid move

  • InvalidGameException — Thrown when game operations are invoked on an unstarted game

  • InvalidPieceInFileException — Thrown when a persisted file contains malformed piece data

  • InvalidPieceTypeInFileException — Thrown when an invalid piece type is encountered in a file

  • InvalidPlayerInFileException — Thrown when player data in a file is malformed

  • InvalidGameStateInFileException — Thrown when the overall game state file is corrupted

  • InvalidBoardInFile — Thrown when board data in a file is invalid

  • InvalidFile — General exception for file parsing errors

  • InvalidNameAlreadyExists — Thrown when attempting to create a game with a name that already exists

  • EndGame — Thrown when the game has ended (not an error, but a state signal)

  • BadStorage — Thrown when storage operations fail

Responsibilities

  • Providing clear, user-friendly error messages

  • Distinguishing between user errors and system errors

  • Supporting graceful error handling throughout the application

  • Enabling specific error handling for different failure scenarios

Types

Link copied to clipboard

Thrown when the storage system fails a health check or encounters a critical error. Indicates that the storage backend is not functioning correctly and may require attention.

Link copied to clipboard
class EndGame(message: String = "The game has ended", type: ErrorType) : ReversiException

Thrown when the game has ended, either due to a winner being determined or both players passing consecutively.

Link copied to clipboard
enum ErrorType(val level: String) : Enum<ErrorType>

Enum representing different types of error levels for exceptions in the Reversi game.

Link copied to clipboard
class InvalidBoardInFile(message: String = "The board in the file is invalid", type: ErrorType) : ReversiException

Thrown when the board representation in the persisted game file is malformed or contains values that cannot be converted into a valid pt.isel.reversi.core.board.Board.

Link copied to clipboard
class InvalidFile(message: String = "The provided file is invalid or corrupted", type: ErrorType) : ReversiException

Thrown when an operation on a file or storage entity fails. This can occur when loading, saving, or deleting game states from persistent storage.

Link copied to clipboard
class InvalidGame(message: String = "The game is invalid or uninitialized", type: ErrorType) : ReversiException

Thrown when an operation is invoked on an invalid or uninitialized game. Examples: calling play or pass when the game has not been started.

Link copied to clipboard
class InvalidGameStateInFile(val message: String = "The game state in the file is invalid", type: ErrorType) : ReversiException

Thrown when a game state in the persisted game file is malformed or contains values that cannot be converted into a valid game state.

Link copied to clipboard
class InvalidNameAlreadyExists(message: String = "The provided name already exists", type: ErrorType = ErrorType.WARNING) : ReversiException

Thrown when attempting to create a game with a name that already exists in storage.

Link copied to clipboard
class InvalidPieceInFile(message: String = "The piece in the file is invalid", type: ErrorType) : ReversiException

Thrown when a piece line in the persisted game file is malformed or contains values that cannot be converted into a valid pt.isel.reversi.core.board.Piece.

Link copied to clipboard
class InvalidPieceTypeInFile(message: String = "The piece type in the file is invalid", type: ErrorType) : ReversiException

Thrown when a pieceType line in the persisted game file is malformed or contains values that cannot be converted into a valid pt.isel.reversi.core.board.PieceType.

Link copied to clipboard
class InvalidPlay(message: String, type: ErrorType) : ReversiException

Thrown when an attempted play is invalid according to Reversi rules. Reasons include: position already occupied, play does not capture any opponent pieces, or the coordinate is out of bounds.

Link copied to clipboard
class InvalidPlayerInFile(message: String = "The player in the file is invalid", type: ErrorType = ErrorType.ERROR) : ReversiException

Thrown when a player line in the persisted game file is malformed or contains values that cannot be converted into a valid pt.isel.reversi.core.gameState.Player.

Link copied to clipboard
abstract class ReversiException(message: String, val type: ErrorType) : Exception

Base exception class for Reversi game-related errors.