01: /*
02: * $Id: JmsExceptionReader.java 10489 2008-01-23 17:53:38Z dfeist $
03: * --------------------------------------------------------------------------------------
04: * Copyright (c) MuleSource, Inc. All rights reserved. http://www.mulesource.com
05: *
06: * The software in this package is published under the terms of the CPAL v1.0
07: * license, a copy of which has been included with this distribution in the
08: * LICENSE.txt file.
09: */
10:
11: package org.mule.transport.jms;
12:
13: import org.mule.api.config.ExceptionReader;
14:
15: import java.util.HashMap;
16: import java.util.Map;
17:
18: import javax.jms.JMSException;
19:
20: /**
21: * This reader will ensure that the LinkedException and JMS code is not lost when
22: * printing the JMSException.
23: */
24: public class JmsExceptionReader implements ExceptionReader {
25:
26: public String getMessage(Throwable t) {
27: JMSException e = (JMSException) t;
28: return e.getMessage() + "(JMS Code: " + e.getErrorCode() + ")";
29: }
30:
31: public Throwable getCause(Throwable t) {
32: JMSException e = (JMSException) t;
33: Throwable cause = e.getLinkedException();
34: if (cause == null) {
35: cause = e.getCause();
36: }
37: return cause;
38: }
39:
40: public Class getExceptionType() {
41: return JMSException.class;
42: }
43:
44: /**
45: * Returns a map of the non-stanard information stored on the exception
46: *
47: * @return a map of the non-stanard information stored on the exception
48: */
49: public Map getInfo(Throwable t) {
50: JMSException e = (JMSException) t;
51: Map info = new HashMap();
52: info.put("JMS Code", e.getErrorCode());
53: return info;
54: }
55:
56: }
|