Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 336318

Summary: General exception handling strategy
Product: [Modeling] EMF Reporter: Eike Stepper <stepper>
Component: cdo.coreAssignee: Project Inbox <emf.cdo-inbox>
Status: NEW --- QA Contact: Eike Stepper <stepper>
Severity: enhancement    
Priority: P3 CC: caspar_d, martin.fluegge, stefan, vaisegid
Version: 4.13   
Target Milestone: ---   
Hardware: All   
OS: All   
Whiteboard:
Bug Depends on:    
Bug Blocks: 338885    

Description Eike Stepper CLA 2011-02-04 03:06:25 EST
I feel that we should come up with a general exception handling strategy that enables us and our consumers to more easily and more specifically react to exceptional situations.

Something in net4j.util could provide a useful and *semantic* categorization similar to what the SpringFramework does with its abstraction layer over SQL vendor specific error codes and SQLExceptions.

Careful consideration of checked exception versus unchecked exception should also be part of that strategy.
Comment 2 Martin Fluegge CLA 2011-02-04 04:21:06 EST
>I feel that we should come up with a general exception handling strategy that
>enables us and our consumers to more easily and more specifically react to
>exceptional situations.

Making things easier is always a good idea, though I must admit that I do not really get the disadvantages of the current implementation ;)


>Something in net4j.util could provide a useful and *semantic* categorization
>similar to what the SpringFramework does with its abstraction layer over SQL
>vendor specific error codes and SQLExceptions.

Do you mean something like wrapping all external exceptions (e.g. store implementation specific exceptions) to something CDO/Net4J specific? 

E.g. if we discover a network failure we through something like a *org.eclipse.net4j.SomethingWasTerriblyWrongWithTheUnderlyingCommunicationChannelException* instead of providing the native exception from the communication implementation (e.g. tcp, http)?
Comment 3 Eike Stepper CLA 2011-02-04 05:16:09 EST
(In reply to comment #2)
> I must admit that I do not really get the disadvantages of the 
> current implementation ;)

Yeah, examples/use cases are always good.

One recently came up with fail-over sessions. Their whole purpose can be defined as "recover somehow after network problems". But as of now they can not easily distinguish between unanticipatable network/IOExceptions and those that occur during request processing within the server.

I'll think about more examples. Others: please also contribute your (bad) experiences with our exception handling!

> Do you mean something like wrapping all external exceptions (e.g. store
> implementation specific exceptions) to something CDO/Net4J specific? 

Wrapping of checked exceptions and exceptions that don't properly aghere to our to-be-specified strategy could be one approach. Please note that this would really involve the wrapping of the native *methods* that throw these exceptions!

Something CDO/Net4J specific? It could be the case that we don't find the exceptions classes that we'd need to implement our to-be-specified strategy somewhere outside of Net4j/CDO. But I feel that at first these execeptions should have general applicable semantics, because these would be the terms that users use to thin in.

> E.g. if we discover a network failure we through something like a
> *org.eclipse.net4j.

util.

> SomethingWasTerriblyWrongWithTheUnderlyingCommunicationChannelException*
> instead of providing the native exception from the communication implementation
> (e.g. tcp, http)?

Yes.
Comment 4 Caspar D. CLA 2011-02-04 05:43:11 EST
> One recently came up with fail-over sessions. Their whole purpose can be
> defined as "recover somehow after network problems". But as of now they
> can not easily distinguish between unanticipatable network/IOExceptions
> and those that occur during request processing within the server.

Actually I'm not sure this is a good example. IMO, my recovery logic was
simply flawed in that it didn't bother to check at all what kind of
exception it was handling. I just fixed that by making it check whether it's
an instanceof TransportException. Seems to work. (Bug 335830)
Comment 5 Caspar D. CLA 2011-02-04 06:03:59 EST
> Careful consideration of checked exception versus unchecked exception should
> also be part of that strategy.

Here's my preferred strategy: don't use checked exceptions.

No need for me to explain why cause the web is ridden with such
explanations. If you Google for 'checked exceptions' you'll
notice that apart from the top 3 or 4 hits, all posts are about
why *not* to use them.
Comment 6 Eike Stepper CLA 2011-02-04 06:43:07 EST
(In reply to comment #5)

I mostly agree and we almost have no checked exception in Net4j or CDO. Though I feel that checked exceptions are a means to force users to care about expectable problems tat they do have a chance to recover from, e.g. our CMEs from TransactionCommitContext.

Just in case you agree, that would bring up the technical challenge to have a whole hierarchy of meaningful, semantic exceptions and make only parts of it checked. E.g. how would our CommitException fit into this picture?
Comment 7 Eike Stepper CLA 2011-02-04 06:53:57 EST
(In reply to comment #4)
> Actually I'm not sure this is a good example. IMO, my recovery logic was
> simply flawed in that it didn't bother to check at all what kind of
> exception it was handling. I just fixed that by making it check whether it's
> an instanceof TransportException. Seems to work. (Bug 335830)

In fact TransportException is one of the few examples where we do have a meaningful exception class. But what about IOExceptions? I added that question to the bug you mention.
Comment 8 Eike Stepper CLA 2011-06-23 03:58:16 EDT
Moving all open enhancement requests to 4.1
Comment 9 Eike Stepper CLA 2012-08-14 22:56:46 EDT
Moving all open issues to 4.2. Open bugs can be ported to 4.1 maintenance after they've been fixed in master.
Comment 10 Eike Stepper CLA 2013-06-27 04:07:23 EDT
Moving all outstanding enhancements to 4.3
Comment 11 Eike Stepper CLA 2014-08-19 09:25:44 EDT
Moving all open enhancement requests to 4.4
Comment 12 Eike Stepper CLA 2014-08-19 09:36:15 EDT
Moving all open enhancement requests to 4.4
Comment 13 Eike Stepper CLA 2015-07-14 02:19:58 EDT
Moving all open bugzillas to 4.5.
Comment 14 Eike Stepper CLA 2016-07-31 01:02:45 EDT
Moving all unaddressed bugzillas to 4.6.
Comment 15 Eike Stepper CLA 2017-12-28 01:11:27 EST
Moving all open bugs to 4.7
Comment 16 Eike Stepper CLA 2019-11-08 02:10:01 EST
Moving all unresolved issues to version 4.8-
Comment 17 Eike Stepper CLA 2019-12-13 12:53:53 EST
Moving all unresolved issues to version 4.9
Comment 18 Eike Stepper CLA 2020-12-11 10:37:28 EST
Moving to 4.13.