Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Exception Interceptor Throws Advice

 
nazzy khan
Ranch Hand
Posts: 39
Android Eclipse IDE Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

I have created a throws advice for my command bean (Login.java) for handling exception and logging when exception is thrown from my command.

Call
LoginAction -> Login command

Both action and command is defined in ApplicationContext.xml file as below



When an exception is thrown from my command, my interceptor class (com.xyz.ExceptionInterceptor.java) will be called. I'm throwing NullPointerException from command. I want the exact line of the command class from where exception is thrown.

ex.getClass().getName() prints only "java.lang.NullPointerException"but not the line no.


code below:



prints
Caught: java.lang.NullPointerException
Class: Login
Method: doExecute

How do I get the line no in ExceptionInterceptor class?


-nazzy
 
nazzy khan
Ranch Hand
Posts: 39
Android Eclipse IDE Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Sorry my bad.. It was very easy.

I have not tried printStackTrace()

getMessage returned null.. then I thought printStackTrace() will also not work.


printStackTrace() returns the complete stack trace along with the line where exception is thrown.


Thanks

-nazzy
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic