01: /*
02: * Licensed to the Apache Software Foundation (ASF) under one or more
03: * contributor license agreements. See the NOTICE file distributed with
04: * this work for additional information regarding copyright ownership.
05: * The ASF licenses this file to You under the Apache License, Version 2.0
06: * (the "License"); you may not use this file except in compliance with
07: * the License. You may obtain a copy of the License at
08: *
09: * http://www.apache.org/licenses/LICENSE-2.0
10: *
11: * Unless required by applicable law or agreed to in writing, software
12: * distributed under the License is distributed on an "AS IS" BASIS,
13: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14: * See the License for the specific language governing permissions and
15: * limitations under the License.
16: */
17: package org.apache.servicemix.jbi;
18:
19: import javax.jbi.messaging.Fault;
20: import javax.jbi.messaging.MessageExchange;
21: import javax.jbi.messaging.MessagingException;
22:
23: /**
24: * An exception which is thrown if a fault occurs in some JBI client invocation.
25: *
26: * @version $Revision: 564374 $
27: */
28: public class FaultException extends MessagingException {
29:
30: private final MessageExchange exchange;
31: private final Fault fault;
32:
33: public FaultException(String text, MessageExchange exchange,
34: Fault fault) {
35: super (text);
36: this .exchange = exchange;
37: this .fault = fault;
38: }
39:
40: public static FaultException newInstance(MessageExchange exchange)
41: throws NoFaultAvailableException {
42: Fault fault = exchange.getFault();
43: if (fault == null) {
44: throw new NoFaultAvailableException(exchange);
45: } else {
46: return new FaultException(
47: "Fault occurred invoking server: " + fault,
48: exchange, fault);
49: }
50: }
51:
52: public MessageExchange getExchange() {
53: return exchange;
54: }
55:
56: public Fault getFault() {
57: return fault;
58: }
59:
60: }
|