returnException static method

void returnException(
  1. Object e
)

Handles an exception and prints an appropriate error message.

This method checks the type of the provided exception and prints a corresponding error message. If the exception is a FileSystemException, it prints the message of a CustomFileSystemException and the details of the FileSystemException. If the exception is a CustomException, it prints the message of the CustomException. If the exception is of any other type, it prints a generic error message.

@param e The exception to handle.

Implementation

static void returnException(Object e) {
  if (e is FileSystemException) {
    print(
        " \x1B[1m\u001B[31m[TRANSLATRON]: \x1B[0m\u001B[31m${CustomFileSystemException().message} ${e.message}, path: ${e.path}\u001B[0m");
    return;
  }
  if (e is CustomException) {
    print(
        " \x1B[1m\u001B[31m[TRANSLATRON]: \x1B[0m\u001B[31m${e.message}\u001B[0m");
    return;
  }
  print(
      " \x1B[1m\u001B[31m[TRANSLATRON]: \x1B[0m\u001B[31mAn unknown error occurred! Please try again later.\u001B[0m");
}