本文整理匯總了Java中javax.jms.JMSException.initCause方法的典型用法代碼示例。如果您正苦於以下問題:Java JMSException.initCause方法的具體用法?Java JMSException.initCause怎麽用?Java JMSException.initCause使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類javax.jms.JMSException
的用法示例。
在下文中一共展示了JMSException.initCause方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: create
import javax.jms.JMSException; //導入方法依賴的package包/類
/**
* Creates or passes through a JMSException to be thrown to the client.
*
* In the event that the exception passed to this method is already a
* JMSException it is passed through unmodified, otherwise a new JMSException
* is created with the given message and the cause is set to the given
* cause Throwable instance.
*
* @param message
* The message value to set when a new JMSException is created.
* @param cause
* The exception that caused this error state.
*
* @return a JMSException instance.
*/
public static JMSException create(String message, Throwable cause) {
if (cause instanceof JMSException) {
return (JMSException) cause;
}
if (cause.getCause() instanceof JMSException) {
return (JMSException) cause.getCause();
}
if (message == null || message.isEmpty()) {
message = cause.getMessage();
if (message == null || message.isEmpty()) {
message = cause.toString();
}
}
JMSException exception = new JMSException(message);
if (cause instanceof Exception) {
exception.setLinkedException((Exception) cause);
}
exception.initCause(cause);
return exception;
}
示例2: newJMSException
import javax.jms.JMSException; //導入方法依賴的package包/類
public static JMSException newJMSException(Throwable t) {
if (t instanceof JMSException) {
return (JMSException) t;
}
JMSException se = new JMSException(t.getMessage());
return (JMSException) se.initCause(t);
}