001 /**
002 * Licensed to the Apache Software Foundation (ASF) under one or more
003 * contributor license agreements. See the NOTICE file distributed with
004 * this work for additional information regarding copyright ownership.
005 * The ASF licenses this file to You under the Apache License, Version 2.0
006 * (the "License"); you may not use this file except in compliance with
007 * the License. You may obtain a copy of the License at
008 *
009 * http://www.apache.org/licenses/LICENSE-2.0
010 *
011 * Unless required by applicable law or agreed to in writing, software
012 * distributed under the License is distributed on an "AS IS" BASIS,
013 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
014 * See the License for the specific language governing permissions and
015 * limitations under the License.
016 */
017 package org.apache.camel;
018
019 import java.util.List;
020
021 /**
022 * A {@link org.apache.camel.spi.UnitOfWork} failed with a number of caused exceptions.
023 * <p/>
024 * This implementation will provide the first exception from the list in its cause, so its shown
025 * in the stacktrace etc when logging this exception. But the remainder exceptions is only available
026 * from the {@link #getCauses()} method.
027 */
028 public class CamelUnitOfWorkException extends CamelExchangeException {
029 private static final long serialVersionUID = 1L;
030 private final List<Exception> causes;
031
032 public CamelUnitOfWorkException(Exchange exchange, List<Exception> causes) {
033 // just provide the first exception as cause, as it will be logged in the stacktraces
034 super("Unit of work failed on exchange with " + causes.size()
035 + " caused exceptions. First exception provided as cause to this exception.", exchange, causes.get(0));
036 this.causes = causes;
037 }
038
039 public List<Exception> getCauses() {
040 return causes;
041 }
042 }