Devo pegar todas as exceções lançadas por um método?

try{
   output.format("%d %s %s %.2f%n", input.nextInt(),
        input.next(),input.next(),input.nextDouble());
} catch(FormatterClosedException formatterClosedException){
    System.err.println("Error writing to file. Terminating.");
    break;
} catch(NoSuchElementException noSuchElementException){
    System.err.println("Invalid input. Please try again.");
    input.nextLine();
}

O métodoformat(String format, Object... args) noFormatter classe lança doisexception: IllegalFormatException eFormatterClosedException mas no meu livro o código acima pegaNoSuchElementException eFormatterClosedException.

Por que o código pegouNoSuchElementException mas não pegouIllegalFormatException?Como podemos saber se precisamos pegarNoSuchElementException se ele nem estiver indicado no método formatter () da classe Formatter no diretório onlinedocumentação ?

questionAnswers(3)

yourAnswerToTheQuestion