On 25 Jan 2006 06:34:53 -0800,
wrote:
> I have the following code in a subroutine of a class which is
> intended to give the user (me) some information as to the nature of
> the error. In addition I want to include in the MessageDialog the
> name of the method that invoked the error.
> How do I get hold of the method name when running?
[...]
> } catch (ParserConfigurationException pce) {
>
> JOptionPane.showMessageDialog(
> null,
> "explicit error message",
> ??????.getMethodName() + " ParserConfigurationException - Error!",
Read the documentation for java.lang.Throwable. This is what you need:
pce.getStackTrace()[0].getMethodName();
/gordon
--
[ do not email me copies of your followups ]
g o r d o n + n e w s @ b a l d e r 1 3 . s e