-1

I am trying to fire the test() method (which uses elements from the JAudioTagger library) when a JavaFX Button is clicked:

search.setOnAction(new EventHandler<ActionEvent>() {
    public void handle(ActionEvent e) {
        test();
    }
});

And here is the test() method:

public void test() throws CannotReadException, IOException, TagException, ReadOnlyFileException, InvalidAudioFrameException {
    ...
}

For some reason, Eclipse has underlined the reference to test() in the first bit of code, saying that

Unhandled exception type InvalidAudioFrameException

even though this exception has already been handled in the test() method? I don't get it.

ilse2005
  • 11,189
  • 5
  • 51
  • 75

1 Answers1

0

Your test method 'claims' it throws the exception. If you declare it in your throws clause, the caller of the method must be prepared to either catch it or add it to it's throws clause.

pczeus
  • 7,709
  • 4
  • 36
  • 51
  • I tried adding the necessary exceptions to the handle() method's clause, but then it says that the exception is not compatible with the throws clause in EventHandler.handle(ActionEvent) – user6000020 Mar 01 '16 at 00:00
  • @user6000020: then handle in a try catch block. All you're doing by posting this question and the comment above is to show us that you've not taken the necessary steps of reading any tutorial on how to handle exceptions. Please fix this soon. – Hovercraft Full Of Eels Mar 01 '16 at 00:05