Package amadeus.brain

Class AmadeusException

All Implemented Interfaces:
Serializable

public class AmadeusException extends Exception
Represents a custom exception class for handling domain-specific errors in the Amadeus application.

This class extends Exception and provides static factory methods to create exceptions for different error scenarios, such as invalid commands, missing arguments, invalid task formats, and database errors.

See Also:
  • Constructor Details

    • AmadeusException

      public AmadeusException(String message)
      Constructs an AmadeusException with a specified error message.
      Parameters:
      message - The detailed error message explaining the exception.
  • Method Details

    • invalidCommand

      public static AmadeusException invalidCommand()
      Creates an exception indicating an invalid command was entered.

      This exception is thrown when the user inputs a command that is not recognized by the application.

      Returns:
      An AmadeusException with a message prompting the user to view available commands.
    • missingArgument

      public static AmadeusException missingArgument(String type)
      Creates an exception indicating a required argument is missing.

      This exception is thrown when the user fails to provide a necessary argument, such as a task description.

      Parameters:
      type - The type of task (e.g., "todo", "deadline", "event") for which the argument is missing.
      Returns:
      An AmadeusException indicating the missing argument.
    • invalidDeadline

      public static AmadeusException invalidDeadline()
      Creates an exception indicating an invalid deadline format.

      This exception is thrown when the user enters a deadline task with an incorrect format.

      Returns:
      An AmadeusException indicating the correct deadline format.
    • invalidEvent

      public static AmadeusException invalidEvent()
      Creates an exception indicating an invalid event format.

      This exception is thrown when the user enters an event task with an incorrect format.

      Returns:
      An AmadeusException indicating the correct event format.
    • invalidEventTime

      public static AmadeusException invalidEventTime()
      Creates an exception indicating an invalid event time range.

      This exception is thrown when the event's start time is after its end time.

      Returns:
      An AmadeusException indicating that the event time range is invalid.
    • invalidCheck

      public static AmadeusException invalidCheck()
      Creates an exception indicating an invalid check command format.

      This exception is thrown when the user enters a check command with an incorrect format.

      Returns:
      An AmadeusException indicating the correct check command format.
    • missingNumber

      public static AmadeusException missingNumber()
      Creates an exception indicating a missing task index.

      This exception is thrown when the user does not provide an index for commands like `mark`, `unmark`, or `delete`.

      Returns:
      An AmadeusException prompting the user to provide a task index.
    • invalidNumber

      public static AmadeusException invalidNumber()
      Creates an exception indicating an invalid task index format.

      This exception is thrown when the user provides an index that is not a valid number.

      Returns:
      An AmadeusException prompting the user to provide a valid numeric task index.
    • invalidIndex

      public static AmadeusException invalidIndex()
      Creates an exception indicating an out-of-bounds task index.

      This exception is thrown when the user provides an index that is outside the range of the task list.

      Returns:
      An AmadeusException indicating that the task index was not found.
    • invalidDate

      public static AmadeusException invalidDate()
      Creates an exception indicating an invalid date format.

      This exception is thrown when the user provides a date that does not match the expected format.

      Returns:
      An AmadeusException prompting the user to provide a date in a valid format.
    • errorSavingTask

      public static AmadeusException errorSavingTask(String file)
      Creates an exception for errors while saving tasks to the file. This is thrown when an IOException occurs during the save operation.
      Parameters:
      file - The error message from the IOException.
      Returns:
      An AmadeusException with a message indicating the error while saving tasks.
    • errorLoadingTask

      public static AmadeusException errorLoadingTask(String file)
      Creates an exception for errors while loading tasks from the file. This is thrown when an IOException occurs during the load operation.
      Parameters:
      file - The error message from the IOException.
      Returns:
      An AmadeusException with a message indicating the error while loading tasks.
    • invalidTaskType

      public static AmadeusException invalidTaskType(String type)
      Creates an exception for an unrecognized task type found in the saved file.
      Parameters:
      type - The invalid task type found (e.g., not "T", "D", or "E").
      Returns:
      An AmadeusException indicating the invalid task type.
    • errorParsingTask

      public static AmadeusException errorParsingTask(String line)
      Creates an exception for errors while parsing a task from the saved file. This is thrown when a line in the file cannot be parsed into a valid task.
      Parameters:
      line - The line from the file that caused the parsing error.
      Returns:
      An AmadeusException with a message indicating the error while parsing the task.