Return-Path: Delivered-To: apmail-activemq-commits-archive@www.apache.org Received: (qmail 51905 invoked from network); 5 Feb 2009 15:26:00 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 5 Feb 2009 15:26:00 -0000 Received: (qmail 17098 invoked by uid 500); 5 Feb 2009 15:26:00 -0000 Delivered-To: apmail-activemq-commits-archive@activemq.apache.org Received: (qmail 17078 invoked by uid 500); 5 Feb 2009 15:25:59 -0000 Mailing-List: contact commits-help@activemq.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@activemq.apache.org Delivered-To: mailing list commits@activemq.apache.org Received: (qmail 17069 invoked by uid 99); 5 Feb 2009 15:25:59 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 05 Feb 2009 07:25:59 -0800 X-ASF-Spam-Status: No, hits=-2000.0 required=10.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 05 Feb 2009 15:25:58 +0000 Received: by eris.apache.org (Postfix, from userid 65534) id CC50C2388896; Thu, 5 Feb 2009 15:25:38 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r741133 - in /activemq/activemq-cpp/trunk/src: main/cms/CMSException.h main/decaf/lang/Throwable.h test/activemq/exceptions/ActiveMQExceptionTest.cpp test/testRegistry.cpp Date: Thu, 05 Feb 2009 15:25:37 -0000 To: commits@activemq.apache.org From: tabish@apache.org X-Mailer: svnmailer-1.0.8 Message-Id: <20090205152538.CC50C2388896@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Author: tabish Date: Thu Feb 5 15:25:37 2009 New Revision: 741133 URL: http://svn.apache.org/viewvc?rev=741133&view=rev Log: https://issues.apache.org/activemq/browse/AMQCPP-218 Make std::exception the virtual base class of the exception types so that ActiveMQException can be a Decaf Exception and a CMSException and still be automatically converted to std::exception in the catch clause. Modified: activemq/activemq-cpp/trunk/src/main/cms/CMSException.h activemq/activemq-cpp/trunk/src/main/decaf/lang/Throwable.h activemq/activemq-cpp/trunk/src/test/activemq/exceptions/ActiveMQExceptionTest.cpp activemq/activemq-cpp/trunk/src/test/testRegistry.cpp Modified: activemq/activemq-cpp/trunk/src/main/cms/CMSException.h URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/src/main/cms/CMSException.h?rev=741133&r1=741132&r2=741133&view=diff ============================================================================== --- activemq/activemq-cpp/trunk/src/main/cms/CMSException.h (original) +++ activemq/activemq-cpp/trunk/src/main/cms/CMSException.h Thu Feb 5 15:25:37 2009 @@ -32,7 +32,7 @@ * This class represents an error that has occurred in * cms. */ - class CMS_API CMSException : public std::exception { + class CMS_API CMSException : public virtual std::exception { public: Modified: activemq/activemq-cpp/trunk/src/main/decaf/lang/Throwable.h URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/src/main/decaf/lang/Throwable.h?rev=741133&r1=741132&r2=741133&view=diff ============================================================================== --- activemq/activemq-cpp/trunk/src/main/decaf/lang/Throwable.h (original) +++ activemq/activemq-cpp/trunk/src/main/decaf/lang/Throwable.h Thu Feb 5 15:25:37 2009 @@ -32,7 +32,7 @@ /** * This class represents an error that has occurred. */ - class DECAF_API Throwable : public std::exception { + class DECAF_API Throwable : public virtual std::exception { public: Throwable() throw() {} Modified: activemq/activemq-cpp/trunk/src/test/activemq/exceptions/ActiveMQExceptionTest.cpp URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/src/test/activemq/exceptions/ActiveMQExceptionTest.cpp?rev=741133&r1=741132&r2=741133&view=diff ============================================================================== --- activemq/activemq-cpp/trunk/src/test/activemq/exceptions/ActiveMQExceptionTest.cpp (original) +++ activemq/activemq-cpp/trunk/src/test/activemq/exceptions/ActiveMQExceptionTest.cpp Thu Feb 5 15:25:37 2009 @@ -49,6 +49,38 @@ CPPUNIT_ASSERT( cause != NULL ); } + + try{ + throw ActiveMQException( __FILE__, __LINE__, "TEST" ); + } catch( std::exception& ex ) { + return; + } + + CPPUNIT_FAIL( "Should have returned after catching an std exception." ); + + try{ + + try{ + try{ + throw UnsupportedOperationException( __FILE__, __LINE__, "EXCEPTION" ); + CPPUNIT_FAIL( "Should not get this far." ); + } + AMQ_CATCH_EXCEPTION_CONVERT( Exception, ActiveMQException ) + } + AMQ_CATCH_RETHROW( ActiveMQException ) + + } catch( std::exception& ex ) { + + ActiveMQException* converted = dynamic_cast( &ex ); + + CPPUNIT_ASSERT( converted != NULL ); + CPPUNIT_ASSERT( converted->getCause() != NULL ); + + const UnsupportedOperationException* cause = + dynamic_cast( converted->getCause() ); + + CPPUNIT_ASSERT( cause != NULL ); + } } //////////////////////////////////////////////////////////////////////////////// Modified: activemq/activemq-cpp/trunk/src/test/testRegistry.cpp URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/src/test/testRegistry.cpp?rev=741133&r1=741132&r2=741133&view=diff ============================================================================== --- activemq/activemq-cpp/trunk/src/test/testRegistry.cpp (original) +++ activemq/activemq-cpp/trunk/src/test/testRegistry.cpp Thu Feb 5 15:25:37 2009 @@ -86,10 +86,10 @@ //CPPUNIT_TEST_SUITE_REGISTRATION( activemq::transport::TransportRegistryTest ); //#include //CPPUNIT_TEST_SUITE_REGISTRATION( activemq::transport::IOTransportTest ); -// -//#include -//CPPUNIT_TEST_SUITE_REGISTRATION( activemq::exceptions::ActiveMQExceptionTest ); -// + +#include +CPPUNIT_TEST_SUITE_REGISTRATION( activemq::exceptions::ActiveMQExceptionTest ); + //#include //CPPUNIT_TEST_SUITE_REGISTRATION( activemq::util::LongSequenceGeneratorTest ); //#include