Enum Class ErrorType

java.lang.Object
java.lang.Enum<ErrorType>
it.polimi.ingsw.gc14.ErrorType
All Implemented Interfaces:
Serializable, Comparable<ErrorType>, Constable

public enum ErrorType extends Enum<ErrorType>
Enumeration of error types that can be returned by server-side operations.
  • Enum Constant Details

    • INVALID_USERNAME

      public static final ErrorType INVALID_USERNAME
      The chosen username is already taken by another connected player.
    • USER_ALREADY_CONNECTED

      public static final ErrorType USER_ALREADY_CONNECTED
      The user is already connected to the server.
    • WRONG_PLAYER_NUMBER

      public static final ErrorType WRONG_PLAYER_NUMBER
      The requested number of players is outside the allowed range.
    • SERVER_CRASHED

      public static final ErrorType SERVER_CRASHED
      The server has crashed or become unreachable.
    • SERVER_UNREACHABLE

      public static final ErrorType SERVER_UNREACHABLE
      The server is unreachable.
    • GENERIC_ERROR

      public static final ErrorType GENERIC_ERROR
      A generic, unclassified error occurred.
    • GAME_ALREADY_STARTED

      public static final ErrorType GAME_ALREADY_STARTED
      The game has already started and cannot accept new players.
    • WRONG_ACTION

      public static final ErrorType WRONG_ACTION
      The action attempted is not valid in the current game state.
  • Field Details

    • description

      private final String description
      Human-readable description of this error, returned by toString().
  • Constructor Details

    • ErrorType

      private ErrorType(String description)
      Creates an error type constant with the given human-readable description.
      Parameters:
      description - the message returned by toString().
  • Method Details

    • values

      public static ErrorType[] values()
      Returns an array containing the constants of this enum class, in the order they are declared.
      Returns:
      an array containing the constants of this enum class, in the order they are declared
    • valueOf

      public static ErrorType valueOf(String name)
      Returns the enum constant of this class with the specified name. The string must match exactly an identifier used to declare an enum constant in this class. (Extraneous whitespace characters are not permitted.)
      Parameters:
      name - the name of the enum constant to be returned.
      Returns:
      the enum constant with the specified name
      Throws:
      IllegalArgumentException - if this enum class has no constant with the specified name
      NullPointerException - if the argument is null
    • toString

      public String toString()
      Returns the human-readable description of this error.
      Overrides:
      toString in class Enum<ErrorType>
      Returns:
      the error description string.