diff options
| author | Rafael H. Schloming <rhs@apache.org> | 2008-04-16 13:58:35 +0000 |
|---|---|---|
| committer | Rafael H. Schloming <rhs@apache.org> | 2008-04-16 13:58:35 +0000 |
| commit | 1073c7afaa52467ae565156ae58f7c6d69384949 (patch) | |
| tree | 49f5d7dfe1e7ad90c2a854fb5f7b34b8150fe49f /java | |
| parent | d054b41aaa1466b65c9dc2acf1b22ca98ec3128c (diff) | |
| download | qpid-python-1073c7afaa52467ae565156ae58f7c6d69384949.tar.gz | |
QPID-901: add back ExceptionHelper.java to fix the build
git-svn-id: https://svn.apache.org/repos/asf/incubator/qpid/trunk/qpid@648699 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'java')
| -rw-r--r-- | java/client/src/main/java/org/apache/qpidity/njms/ExceptionHelper.java | 60 |
1 files changed, 60 insertions, 0 deletions
diff --git a/java/client/src/main/java/org/apache/qpidity/njms/ExceptionHelper.java b/java/client/src/main/java/org/apache/qpidity/njms/ExceptionHelper.java new file mode 100644 index 0000000000..e00f9008d3 --- /dev/null +++ b/java/client/src/main/java/org/apache/qpidity/njms/ExceptionHelper.java @@ -0,0 +1,60 @@ +/* Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.qpidity.njms; + +import org.apache.qpidity.QpidException; + +import javax.jms.JMSException; +import javax.transaction.xa.XAException; + +/** + * Helper class for handling exceptions + */ +public class ExceptionHelper +{ + static public JMSException convertQpidExceptionToJMSException(Exception exception) + { + JMSException jmsException = null; + if (!(exception instanceof JMSException)) + { + if (exception instanceof QpidException) + { + jmsException = new JMSException(exception.getMessage(), String.valueOf(((QpidException) exception).getErrorCode())); + } + else + { + jmsException = new JMSException(exception.getMessage()); + } + jmsException.setLinkedException(exception); + jmsException.initCause(exception); + } + else + { + jmsException = (JMSException) exception; + } + return jmsException; + } + + static public XAException convertQpidExceptionToXAException(QpidException exception) + { + String qpidErrorCode = String.valueOf(exception.getErrorCode()); + // todo map this error to an XA code + int xaCode = XAException.XAER_PROTO; + return new XAException(xaCode); + } +} |
