use of org.apache.camel.processor.CatchProcessor in project camel by apache.
the class CatchDefinition method createProcessor.
@Override
public CatchProcessor createProcessor(RouteContext routeContext) throws Exception {
// create and load exceptions if not done
if (exceptionClasses == null) {
exceptionClasses = createExceptionClasses(routeContext.getCamelContext());
}
// must have at least one exception
if (exceptionClasses.isEmpty()) {
throw new IllegalArgumentException("At least one Exception must be configured to catch");
}
// parent must be a try
if (!(getParent() instanceof TryDefinition)) {
throw new IllegalArgumentException("This doCatch should have a doTry as its parent on " + this);
}
// do catch does not mandate a child processor
Processor childProcessor = this.createChildProcessor(routeContext, false);
Predicate when = null;
if (onWhen != null) {
when = onWhen.getExpression().createPredicate(routeContext);
}
Predicate handle = handledPolicy;
if (handled != null) {
handle = handled.createPredicate(routeContext);
}
return new CatchProcessor(exceptionClasses, childProcessor, when, handle);
}
use of org.apache.camel.processor.CatchProcessor in project camel by apache.
the class OnExceptionDefinition method createProcessor.
@Override
public CatchProcessor createProcessor(RouteContext routeContext) throws Exception {
// load exception classes
if (exceptions != null && !exceptions.isEmpty()) {
exceptionClasses = createExceptionClasses(routeContext.getCamelContext().getClassResolver());
}
if (useOriginalMessagePolicy != null && useOriginalMessagePolicy) {
// ensure allow original is turned on
routeContext.setAllowUseOriginalMessage(true);
}
// must validate configuration before creating processor
validateConfiguration();
Processor childProcessor = this.createChildProcessor(routeContext, false);
Predicate when = null;
if (onWhen != null) {
when = onWhen.getExpression().createPredicate(routeContext);
}
Predicate handle = null;
if (handled != null) {
handle = handled.createPredicate(routeContext);
}
return new CatchProcessor(getExceptionClasses(), childProcessor, when, handle);
}
Aggregations