You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by Riggy Software <ri...@hotmail.com> on 2019/01/10 02:33:40 UTC

Exception handling by composition

Hello,

I'm looking for some hints, ideally a clear example if anybody can help.

I try to write reusable route components wherever possible, and where I'm having difficulty is with the
encapsulation of onException clauses to hide specialist exception classes from my generic route.

Something like:

PluggableErrorHandler myPluggableErrorHandler =

new PluggableErrorHandler() {

public void include(){
onException (MySpecialistException.class)
.handle(true)...
}
};

configure() {
    myPluggableErrorHandler.include();

onException (SomeCoreException.class)
.handle(true)...

from(direct:dostuff)
}

I guess I need to write a custom ErrorHandler?
But it's not jumping out at me from the docs, and looks like there could be some pitfalls so I wonder if I'm not looking at it right.

The route is transactional and should remain so, so any custom ErrorHandler should not interfere with that, and also I want my wrapped onException clause to be evaluated first, before the other global onException clauses.

Any guidance will be gratefully received.

Thanks in advance.

Naseem