I'm getting this error: "If any exception other than a NoSuchZipFileException occurs, then display "An error occurred. Please check the entered data."
Even when I copied this to catch statement it didn't pass
package com.codegym.task.task31.task3110;
import com.codegym.task.task31.task3110.exception.NoSuchZipFileException;
import java.io.IOException;
public class Archiver
{
public static void main(String[] args)
{
Operation operation;
while (true)
{
try {
operation = askOperation();
CommandExecutor.execute(operation);
if (operation == Operation.EXIT)
break;
} catch (NoSuchZipFileException e)
{
ConsoleHelper.writeMessage("You didn't select an archive or you selected an invalid file.");
}
catch (Exception e)
{
ConsoleHelper.writeMessage("An error occurred. Please check entered data.");
}
}
}
public static Operation askOperation() throws IOException
{
ConsoleHelper.writeMessage("Select an operation:" + Operation.CREATE.ordinal() + " - Zip files into an archive" );
// ConsoleHelper.writeMessage(Operation.CREATE.ordinal() + " - Zip files into an archive");
ConsoleHelper.writeMessage(Operation.ADD.ordinal() + " - Add a file into an archive");
ConsoleHelper.writeMessage(Operation.REMOVE.ordinal() + " - Remove a file from an archive");
ConsoleHelper.writeMessage(Operation.EXTRACT.ordinal() + " - Extract an archive");
ConsoleHelper.writeMessage(Operation.CONTENT.ordinal() + " - View contents of an archive");
ConsoleHelper.writeMessage(Operation.EXIT.ordinal() + " - Exit");
int operation = ConsoleHelper.readInt();
Operation operation1 = null;
for (Operation e : Operation.values() ) {
if (e.ordinal() == operation)
operation1 = e;
}
return operation1;
}
}