Classes in this File | Line Coverage | Branch Coverage | Complexity | ||||
JmsExceptionReader |
|
| 0.0;0 |
1 | /* | |
2 | * $Id: JmsExceptionReader.java 20321 2010-11-24 15:21:24Z dfeist $ | |
3 | * -------------------------------------------------------------------------------------- | |
4 | * Copyright (c) MuleSoft, Inc. All rights reserved. http://www.mulesoft.com | |
5 | * | |
6 | * The software in this package is published under the terms of the CPAL v1.0 | |
7 | * license, a copy of which has been included with this distribution in the | |
8 | * LICENSE.txt file. | |
9 | */ | |
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 | 0 | public class JmsExceptionReader implements ExceptionReader |
25 | { | |
26 | ||
27 | public String getMessage(Throwable t) | |
28 | { | |
29 | 0 | JMSException e = (JMSException)t; |
30 | 0 | return e.getMessage() + "(JMS Code: " + e.getErrorCode() + ")"; |
31 | } | |
32 | ||
33 | public Throwable getCause(Throwable t) | |
34 | { | |
35 | 0 | JMSException e = (JMSException)t; |
36 | 0 | Throwable cause = e.getLinkedException(); |
37 | 0 | if (cause == null) |
38 | { | |
39 | 0 | cause = e.getCause(); |
40 | } | |
41 | 0 | return cause; |
42 | } | |
43 | ||
44 | public Class<?> getExceptionType() | |
45 | { | |
46 | 0 | return JMSException.class; |
47 | } | |
48 | ||
49 | /** | |
50 | * Returns a map of the non-stanard information stored on the exception | |
51 | * | |
52 | * @return a map of the non-stanard information stored on the exception | |
53 | */ | |
54 | public Map<?, ?> getInfo(Throwable t) | |
55 | { | |
56 | 0 | JMSException e = (JMSException)t; |
57 | 0 | Map<String, Object> info = new HashMap<String, Object>(); |
58 | 0 | info.put("JMS Code", e.getErrorCode()); |
59 | 0 | return info; |
60 | } | |
61 | ||
62 | } |