Apache camel 从exchange获取自定义异常

Apache camel 从exchange获取自定义异常,apache-camel,Apache Camel,我已经声明了我的CustomException类。 当OneException捕捉到它时,它将转到我定义的处理器: onException(classOf[CustomException]).process(doSmth) 到目前为止还不错。 我需要进入处理器以检查异常是否为CustomException类型的问题 当我写作时: def process(exchange: Exchange) = { val exception: Exception = exchange.getProp

我已经声明了我的CustomException类。 当OneException捕捉到它时,它将转到我定义的处理器:

onException(classOf[CustomException]).process(doSmth)
到目前为止还不错。 我需要进入处理器以检查异常是否为CustomException类型的问题

当我写作时:

def process(exchange: Exchange) = {
    val exception: Exception = exchange.getProperty(Exchange.EXCEPTION_CAUGHT, classOf[Exception])
def processexchange:Exchange={ val异常:CustomException=exchange.getPropertyExchange.exception\u已捕获,类别为[CustomException]

我得到零

但当我写作时:

def process(exchange: Exchange) = {
    val exception: Exception = exchange.getProperty(Exchange.EXCEPTION_CAUGHT, classOf[Exception])
我得到了我的异常对象


我如何检查哪种类型的异常被抛出到处理器中!

在Java DSL中,这是有效的

public void process(Exchange exch) throws Exception {
    Exception e = (Exception) exch.getProperty(Exchange.EXCEPTION_CAUGHT);
    if (e instanceof CustomException) {
        logger.info("custom exception");
    } else {
        logger.info("other excpetion");
    }
}