Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Equinox » Best practices for exception handling
Best practices for exception handling [message #68711] Thu, 22 June 2006 12:47 Go to next message
Cameron Ross is currently offline Cameron RossFriend
Messages: 17
Registered: July 2009
Junior Member
Hi,

I'm looking for best practices for dealing with exceptions generated from
within bundle code. Specifically, exceptions generated within
activate(ComponentContext), deactivate(ComponentContext),
handleEvent(Event), and custom component service methods. The first three
methods are defined and called by the framework implying that either
unchecked exceptions should be thrown, or that the issue should be dealt
with by the component directly (i.e. log and leave). Which is best? How
should one deal with exceptions generated within custom service methods?

Any standard approaches or recommendations?

Cheers,
Cameron.
Re: Best practices for exception handling [message #69882 is a reply to message #68711] Thu, 13 July 2006 21:01 Go to previous message
Thomas Watson is currently offline Thomas WatsonFriend
Messages: 503
Registered: July 2009
Senior Member
Hi Cameron,

The methods you mentioned are called using reflection and the spec
states that any exceptions thrown (checked or unchecked) should be
logged by the declarative services runtime implementation. In these
cases the only time you should catch and handle exceptions yourself is
if you are able to continue even though the exception occurred and you
want the activate, deactivate etc. operation to continue even though the
exception occurred. You have to decide how to handle the exception
yourself. For example, if you failed to open a specific port maybe you
can try a different one. If you can only use a specific port then you
can choose to throw the SocketException and have your service component
fail to activate.

HTH

Tom.
Previous Topic:NPE with j9
Next Topic:possible issue with refreshPackages and dynamically importing bundles
Goto Forum:
  


Current Time: Sat Aug 17 17:43:27 GMT 2024

Powered by FUDForum. Page generated in 0.02918 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top