1 18 package org.apache.activemq.util; 19 20 import javax.jms.JMSException ; 21 import javax.jms.MessageEOFException ; 22 import javax.jms.MessageFormatException ; 23 24 final public class JMSExceptionSupport { 25 26 public static JMSException create(String msg, Throwable cause) { 27 JMSException exception = new JMSException (msg); 28 exception.initCause(cause); 29 return exception; 30 } 31 32 public static JMSException create(String msg, Exception cause) { 33 JMSException exception = new JMSException (msg); 34 exception.setLinkedException(cause); 35 exception.initCause(cause); 36 return exception; 37 } 38 39 public static JMSException create(Throwable cause) { 40 if (cause instanceof JMSException ) { 41 return (JMSException ) cause; 42 } 43 String msg = cause.getMessage(); 44 if( msg==null || msg.length()==0 ) 45 msg = cause.toString(); 46 JMSException exception = new JMSException (msg); 47 exception.initCause(cause); 48 return exception; 49 } 50 51 public static JMSException create(Exception cause) { 52 if (cause instanceof JMSException ) { 53 return (JMSException ) cause; 54 } 55 String msg = cause.getMessage(); 56 if( msg==null || msg.length()==0 ) 57 msg = cause.toString(); 58 JMSException exception = new JMSException (msg); 59 exception.setLinkedException(cause); 60 exception.initCause(cause); 61 return exception; 62 } 63 64 public static MessageEOFException createMessageEOFException(Exception cause) { 65 String msg = cause.getMessage(); 66 if( msg==null || msg.length()==0 ) 67 msg = cause.toString(); 68 MessageEOFException exception = new MessageEOFException (msg); 69 exception.setLinkedException(cause); 70 exception.initCause(cause); 71 return exception; 72 } 73 74 public static MessageFormatException createMessageFormatException(Exception cause) { 75 String msg = cause.getMessage(); 76 if( msg==null || msg.length()==0 ) 77 msg = cause.toString(); 78 MessageFormatException exception = new MessageFormatException (msg); 79 exception.setLinkedException(cause); 80 exception.initCause(cause); 81 return exception; 82 } 83 } 84 | Popular Tags |