I want to make a generalized Exception handling in my program. It should show an JOptionPane.showMessageDialog(null, "There was an unexpected Exception: ");
liek this. Now I also want to add the necessary information to the dialog. I know how to get the type of the exception (e.getClass();
), but is there a way to only get the information like which class/method and which line?
Example for the exception:
at com.mainfirst.bloomberg.invoice.report.Etst.main(Etst.java:35)
I would like to only get the part inside the brackets. i tried Thread.currentThread().getStackTrace()[2].getLineNumber()
what i found in a similar question, but this returned null, so i tried with other indexes and index 1 returns the line the Thread.currentThread()...
is written in. Is there way to retrieve the information i need?