ASG
IBM
Zystems
Cressida
Icon
Netflexity
 
  MQSeries.net
Search  Search       Tech Exchange      Education      Certifications      Library      Info Center      SupportPacs      LinkedIn  Search  Search                                                                   FAQ  FAQ   Usergroups  Usergroups
 
Register  ::  Log in Log in to check your private messages
 
RSS Feed - WebSphere MQ Support RSS Feed - Message Broker Support

MQSeries.net Forum Index » WebSphere Message Broker (ACE) Support » "throw" exception not getting caught

Post new topic  Reply to topic Goto page Previous  1, 2
 "throw" exception not getting caught « View previous topic :: View next topic » 
Author Message
Esa
PostPosted: Fri Mar 08, 2013 4:11 am    Post subject: Reply with quote

Grand Master

Joined: 22 May 2008
Posts: 1387
Location: Finland

fjb_saper wrote:
rekarm01 wrote:

Why? What's the point of catching the exception, doing nothing with it, and then rethrowing it? How is that different from simply not adding the catch block, and not catching the exception?


I believe the point here is eclipse requiring you to either catch the exception or explicitly requiring a throws statement in the method signature...


I don't think so. MbBrokerException is an instance of RuntimeException...
Back to top
View user's profile Send private message
rekarm01
PostPosted: Fri Mar 08, 2013 10:29 am    Post subject: Reply with quote

Grand Master

Joined: 25 Jun 2008
Posts: 1415

fjb_saper wrote:
I believe the point here is eclipse requiring you to either catch the exception or explicitly requiring a throws statement in the method signature...

Even if that were the case, putting a throw statement in the catch block would not affect the need for a throws clause in the method signature. The method would still throw the same Exception, with or without the catch block (as written).

Esa wrote:
MbBrokerException is an instance of RuntimeException...

... and is not normally meant for the JCN to catch.
Back to top
View user's profile Send private message
rvmson
PostPosted: Tue Mar 12, 2013 5:16 am    Post subject: Reply with quote

Newbie

Joined: 06 Mar 2013
Posts: 6

Quote:
"Why? What's the point of catching the exception, doing nothing with it, and then rethrowing it? How is that different from simply not adding the catch block, and not catching the exception?"


If you have no other exceptions to catch and handle, there would not be much value in adding in a catch and rethrow for the MbBrokerException.

But if you have other exceptions to catch and handle within the JCN, catching and rethrowing MbBrokerException is appropriate.
Back to top
View user's profile Send private message
Esa
PostPosted: Tue Mar 12, 2013 5:46 am    Post subject: Reply with quote

Grand Master

Joined: 22 May 2008
Posts: 1387
Location: Finland

rvmson wrote:
Quote:
"Why? What's the point of catching the exception, doing nothing with it, and then rethrowing it? How is that different from simply not adding the catch block, and not catching the exception?"


If you have no other exceptions to catch and handle, there would not be much value in adding in a catch and rethrow for the MbBrokerException.

But if you have other exceptions to catch and handle within the JCN, catching and rethrowing MbBrokerException is appropriate.


Yes.
To be more precise: If you want to process any RuntimeExceptions that may be caused by your java code or classes called by it, you need to explicitly catch RuntimeException and rethrow those that are instances of MbBrokerException.
Back to top
View user's profile Send private message
rekarm01
PostPosted: Wed Mar 20, 2013 12:20 am    Post subject: Reply with quote

Grand Master

Joined: 25 Jun 2008
Posts: 1415

rvmson wrote:
If you have no other exceptions to catch and handle, there would not be much value in adding in a catch and rethrow for the MbBrokerException.

But if you have other exceptions to catch and handle within the JCN, catching and rethrowing MbBrokerException is appropriate.

That's an important point, that seemed to be overlooked in the previous post, but it's only relevant if the other exceptions are superclasses of MbBrokerExceptions. Whether it's appropriate for the JCN to be catching and handling such superclass exceptions without rethrowing them is another matter ...

Getting back to the OP's example, the more relevant question is whether the JCN should be catching and handling downstream exceptions (from the propagate() method).
Back to top
View user's profile Send private message
Esa
PostPosted: Wed Mar 20, 2013 12:40 am    Post subject: Reply with quote

Grand Master

Joined: 22 May 2008
Posts: 1387
Location: Finland

rekarm01 wrote:

That's an important point, that seemed to be overlooked in the previous post, but it's only relevant if the other exceptions are superclasses of MbBrokerExceptions. Whether it's appropriate for the JCN to be catching and handling such superclass exceptions without rethrowing them is another matter ...

Getting back to the OP's example, the more relevant question is whether the JCN should be catching and handling downstream exceptions (from the propagate() method).


Hmm....

MbBrokerException is a direct descendant of java.lang.RuntimeException...

So the other possible superclasses are java.lang.Exception or java.lang.Throwable...

Downstream exceptions will be instances of MbBrokerException...
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic  Reply to topic Goto page Previous  1, 2 Page 2 of 2

MQSeries.net Forum Index » WebSphere Message Broker (ACE) Support » "throw" exception not getting caught
Jump to:  



You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
Protected by Anti-Spam ACP
 
 


Theme by Dustin Baccetti
Powered by phpBB © 2001, 2002 phpBB Group

Copyright © MQSeries.net. All rights reserved.