catch by constant reference

This commit is contained in:
Takeshi Abe
2011-11-30 11:05:16 +09:00
parent 2b2f6abfcc
commit 7113c7152d
17 changed files with 44 additions and 44 deletions

View File

@@ -108,7 +108,7 @@ void Test::testTypeOfVoidSequence() {
try { try {
m.readType(); m.readType();
CPPUNIT_FAIL("exception expected"); CPPUNIT_FAIL("exception expected");
} catch (css::io::IOException &) {} } catch (const css::io::IOException &) {}
} }
CPPUNIT_TEST_SUITE_REGISTRATION(Test); CPPUNIT_TEST_SUITE_REGISTRATION(Test);

View File

@@ -259,7 +259,7 @@ void Bridge::terminate() {
} }
try { try {
connection_->close(); connection_->close();
} catch (css::io::IOException & e) { } catch (const css::io::IOException & e) {
SAL_INFO("binaryurp", "caught IO exception '" << e.Message << '\''); SAL_INFO("binaryurp", "caught IO exception '" << e.Message << '\'');
} }
assert(w.is()); assert(w.is());
@@ -289,7 +289,7 @@ void Bridge::terminate() {
(*i)->disposing( (*i)->disposing(
css::lang::EventObject( css::lang::EventObject(
static_cast< cppu::OWeakObject * >(this))); static_cast< cppu::OWeakObject * >(this)));
} catch (css::uno::RuntimeException & e) { } catch (const css::uno::RuntimeException & e) {
SAL_WARN( SAL_WARN(
"binaryurp", "caught runtime exception '" << e.Message << '\''); "binaryurp", "caught runtime exception '" << e.Message << '\'');
} }
@@ -505,10 +505,10 @@ void Bridge::revokeProxy(Proxy & proxy) {
void Bridge::freeProxy(Proxy & proxy) { void Bridge::freeProxy(Proxy & proxy) {
try { try {
makeReleaseCall(proxy.getOid(), proxy.getType()); makeReleaseCall(proxy.getOid(), proxy.getType());
} catch (css::uno::RuntimeException & e) { } catch (const css::uno::RuntimeException & e) {
SAL_INFO( SAL_INFO(
"binaryurp", "caught runtime exception '" << e.Message << '\''); "binaryurp", "caught runtime exception '" << e.Message << '\'');
} catch (std::exception & e) { } catch (const std::exception & e) {
SAL_WARN("binaryurp", "caught C++ exception '" << e.what() << '\''); SAL_WARN("binaryurp", "caught C++ exception '" << e.what() << '\'');
} }
bool unused; bool unused;
@@ -660,7 +660,7 @@ void Bridge::handleCommitChangeReply(
bool ccMode = true; bool ccMode = true;
try { try {
throwException(exception, returnValue); throwException(exception, returnValue);
} catch (css::bridge::InvalidProtocolChangeException &) { } catch (const css::bridge::InvalidProtocolChangeException &) {
ccMode = false; ccMode = false;
} }
if (ccMode) { if (ccMode) {

View File

@@ -87,7 +87,7 @@ void IncomingRequest::execute() const {
try { try {
try { try {
isExc = !execute_throw(&ret, &outArgs); isExc = !execute_throw(&ret, &outArgs);
} catch (std::exception & e) { } catch (const std::exception & e) {
throw css::uno::RuntimeException( throw css::uno::RuntimeException(
(rtl::OUString( (rtl::OUString(
RTL_CONSTASCII_USTRINGPARAM("caught C++ exception: ")) + RTL_CONSTASCII_USTRINGPARAM("caught C++ exception: ")) +
@@ -96,7 +96,7 @@ void IncomingRequest::execute() const {
css::uno::Reference< css::uno::XInterface >()); css::uno::Reference< css::uno::XInterface >());
// best-effort string conversion // best-effort string conversion
} }
} catch (css::uno::RuntimeException &) { } catch (const css::uno::RuntimeException &) {
css::uno::Any exc(cppu::getCaughtException()); css::uno::Any exc(cppu::getCaughtException());
ret = bridge_->mapCppToBinaryAny(exc); ret = bridge_->mapCppToBinaryAny(exc);
isExc = true; isExc = true;
@@ -104,7 +104,7 @@ void IncomingRequest::execute() const {
if (resetCc) { if (resetCc) {
current_context::set(oldCc); current_context::set(oldCc);
} }
} catch (css::uno::RuntimeException &) { } catch (const css::uno::RuntimeException &) {
css::uno::Any exc(cppu::getCaughtException()); css::uno::Any exc(cppu::getCaughtException());
ret = bridge_->mapCppToBinaryAny(exc); ret = bridge_->mapCppToBinaryAny(exc);
isExc = true; isExc = true;
@@ -115,12 +115,12 @@ void IncomingRequest::execute() const {
bridge_->getWriter()->queueReply( bridge_->getWriter()->queueReply(
tid_, member_, setter_, isExc, ret, outArgs, false); tid_, member_, setter_, isExc, ret, outArgs, false);
return; return;
} catch (css::uno::RuntimeException & e) { } catch (const css::uno::RuntimeException & e) {
OSL_TRACE( OSL_TRACE(
OSL_LOG_PREFIX "caught UNO runtime exception '%s'", OSL_LOG_PREFIX "caught UNO runtime exception '%s'",
(rtl::OUStringToOString(e.Message, RTL_TEXTENCODING_UTF8). (rtl::OUStringToOString(e.Message, RTL_TEXTENCODING_UTF8).
getStr())); getStr()));
} catch (std::exception & e) { } catch (const std::exception & e) {
OSL_TRACE(OSL_LOG_PREFIX "caught C++ exception '%s'", e.what()); OSL_TRACE(OSL_LOG_PREFIX "caught C++ exception '%s'", e.what());
} }
bridge_->terminate(); bridge_->terminate();
@@ -162,7 +162,7 @@ bool IncomingRequest::execute_throw(
if (prov.is()) { if (prov.is()) {
try { try {
ifc = prov->getInstance(oid_); ifc = prov->getInstance(oid_);
} catch (css::container::NoSuchElementException & e) { } catch (const css::container::NoSuchElementException & e) {
OSL_TRACE( OSL_TRACE(
(OSL_LOG_PREFIX "initial element '%s':" (OSL_LOG_PREFIX "initial element '%s':"
" NoSuchElementException '%s'"), " NoSuchElementException '%s'"),

View File

@@ -116,7 +116,7 @@ void Proxy::do_dispatch(
try { try {
try { try {
do_dispatch_throw(member, returnValue, arguments, exception); do_dispatch_throw(member, returnValue, arguments, exception);
} catch (std::exception & e) { } catch (const std::exception & e) {
throw css::uno::RuntimeException( throw css::uno::RuntimeException(
(rtl::OUString( (rtl::OUString(
RTL_CONSTASCII_USTRINGPARAM("caught C++ exception: ")) + RTL_CONSTASCII_USTRINGPARAM("caught C++ exception: ")) +
@@ -125,7 +125,7 @@ void Proxy::do_dispatch(
css::uno::Reference< css::uno::XInterface >()); css::uno::Reference< css::uno::XInterface >());
// best-effort string conversion // best-effort string conversion
} }
} catch (css::uno::RuntimeException &) { } catch (const css::uno::RuntimeException &) {
css::uno::Any exc(cppu::getCaughtException()); css::uno::Any exc(cppu::getCaughtException());
uno_copyAndConvertData( uno_copyAndConvertData(
*exception, &exc, *exception, &exc,

View File

@@ -145,9 +145,9 @@ void Reader::run() {
} }
block.done(); block.done();
} }
} catch (css::uno::Exception & e) { } catch (const css::uno::Exception & e) {
SAL_WARN("binaryurp", "caught UNO exception '" << e.Message << '\''); SAL_WARN("binaryurp", "caught UNO exception '" << e.Message << '\'');
} catch (std::exception & e) { } catch (const std::exception & e) {
SAL_WARN("binaryurp", "caught C++ exception '" << e.what() << '\''); SAL_WARN("binaryurp", "caught C++ exception '" << e.what() << '\'');
} }
bridge_->terminate(); bridge_->terminate();

View File

@@ -189,11 +189,11 @@ void Writer::run() {
} }
} }
} }
} catch (css::uno::Exception & e) { } catch (const css::uno::Exception & e) {
OSL_TRACE( OSL_TRACE(
OSL_LOG_PREFIX "caught UNO exception '%s'", OSL_LOG_PREFIX "caught UNO exception '%s'",
rtl::OUStringToOString(e.Message, RTL_TEXTENCODING_UTF8).getStr()); rtl::OUStringToOString(e.Message, RTL_TEXTENCODING_UTF8).getStr());
} catch (std::exception & e) { } catch (const std::exception & e) {
OSL_TRACE(OSL_LOG_PREFIX "caught C++ exception '%s'", e.what()); OSL_TRACE(OSL_LOG_PREFIX "caught C++ exception '%s'", e.what());
} }
bridge_->terminate(); bridge_->terminate();
@@ -447,7 +447,7 @@ void Writer::sendMessage(std::vector< unsigned char > const & buffer) {
rtl_copyMemory(s.getArray() + s.getLength() - k, p, k); rtl_copyMemory(s.getArray() + s.getLength() - k, p, k);
try { try {
bridge_->getConnection()->write(s); bridge_->getConnection()->write(s);
} catch (css::io::IOException & e) { } catch (const css::io::IOException & e) {
css::uno::Any exc(cppu::getCaughtException()); css::uno::Any exc(cppu::getCaughtException());
throw css::lang::WrappedTargetRuntimeException( throw css::lang::WrappedTargetRuntimeException(
(rtl::OUString( (rtl::OUString(

View File

@@ -464,9 +464,9 @@ inline void SAL_CALL cppu_cppenv_computeObjectIdentifier(
::rtl_uString_acquire( *ppOId = aRet.pData ); ::rtl_uString_acquire( *ppOId = aRet.pData );
} }
} }
catch (::com::sun::star::uno::RuntimeException &) catch (const ::com::sun::star::uno::RuntimeException &)
{ {
OSL_FAIL( "### RuntimeException occurred udring queryInterface()!" ); OSL_FAIL( "### RuntimeException occurred during queryInterface()!" );
} }
} }
} }

View File

@@ -332,7 +332,7 @@ void call(
callVirtualMethod( callVirtualMethod(
(*thisPtr)[slot.index + 2], stack, (*thisPtr)[slot.index + 2], stack,
std::max< sal_Int32 >(sp - 6, 0) * sizeof (long)); std::max< sal_Int32 >(sp - 6, 0) * sizeof (long));
} catch (css::uno::Exception &) { } catch (const css::uno::Exception &) {
void * exc = __Crun::ex_get(); void * exc = __Crun::ex_get();
char const * name = __Cimpl::ex_name(); char const * name = __Cimpl::ex_name();
bridges::cpp_uno::cc5_solaris_sparc64::fillUnoException( bridges::cpp_uno::cc5_solaris_sparc64::fillUnoException(

View File

@@ -390,9 +390,9 @@ static void cpp_call(
pStackStart, ( pStack - pStackStart ), pStackStart, ( pStack - pStackStart ),
pGPR, nGPR, pGPR, nGPR,
pFPR, nFPR ); pFPR, nFPR );
} catch (Exception &) { } catch (const Exception &) {
throw; throw;
} catch (std::exception & e) { } catch (const std::exception & e) {
OUStringBuffer buf; OUStringBuffer buf;
buf.appendAscii(RTL_CONSTASCII_STRINGPARAM("C++ code threw ")); buf.appendAscii(RTL_CONSTASCII_STRINGPARAM("C++ code threw "));
appendCString(buf, typeid(e).name()); appendCString(buf, typeid(e).name());

View File

@@ -144,10 +144,10 @@ static void s_stub_computeObjectIdentifier(va_list * pParam)
::rtl_uString_acquire( *ppOId = aRet.pData ); ::rtl_uString_acquire( *ppOId = aRet.pData );
} }
} }
catch (::com::sun::star::uno::RuntimeException &) catch (const ::com::sun::star::uno::RuntimeException &)
{ {
OSL_FAIL( OSL_FAIL(
"### RuntimeException occurred udring queryInterface()!" ); "### RuntimeException occurred during queryInterface()!" );
} }
} }
} }

View File

@@ -106,7 +106,7 @@ void SAL_CALL Mapping_map_to_uno(
} }
*ppUnoI = pUnoI; *ppUnoI = pUnoI;
} }
catch (BridgeRuntimeError & err) catch (const BridgeRuntimeError & err)
{ {
#if OSL_DEBUG_LEVEL > 0 #if OSL_DEBUG_LEVEL > 0
OString cstr_msg( OString cstr_msg(
@@ -118,7 +118,7 @@ void SAL_CALL Mapping_map_to_uno(
(void) err; // unused (void) err; // unused
#endif #endif
} }
catch (::jvmaccess::VirtualMachine::AttachGuard::CreationException &) catch (const ::jvmaccess::VirtualMachine::AttachGuard::CreationException &)
{ {
OSL_FAIL( OSL_FAIL(
"[jni_uno bridge error] attaching current thread " "[jni_uno bridge error] attaching current thread "
@@ -175,7 +175,7 @@ void SAL_CALL Mapping_map_to_java(
jni->DeleteLocalRef( jlocal ); jni->DeleteLocalRef( jlocal );
} }
} }
catch (BridgeRuntimeError & err) catch (const BridgeRuntimeError & err)
{ {
#if OSL_DEBUG_LEVEL > 0 #if OSL_DEBUG_LEVEL > 0
OString cstr_msg( OString cstr_msg(
@@ -187,7 +187,7 @@ void SAL_CALL Mapping_map_to_java(
(void) err; // unused (void) err; // unused
#endif #endif
} }
catch (::jvmaccess::VirtualMachine::AttachGuard::CreationException &) catch (const ::jvmaccess::VirtualMachine::AttachGuard::CreationException &)
{ {
OSL_FAIL( OSL_FAIL(
"[jni_uno bridge error] attaching current thread to java failed!" ); "[jni_uno bridge error] attaching current thread to java failed!" );
@@ -537,7 +537,7 @@ void SAL_CALL uno_ext_getMapping(
(uno_Environment *)pFrom->pExtEnv, pTo, 0 ); (uno_Environment *)pFrom->pExtEnv, pTo, 0 );
} }
} }
catch (BridgeRuntimeError & err) catch (const BridgeRuntimeError & err)
{ {
#if OSL_DEBUG_LEVEL > 0 #if OSL_DEBUG_LEVEL > 0
OString cstr_msg( OString cstr_msg(
@@ -549,7 +549,7 @@ void SAL_CALL uno_ext_getMapping(
(void) err; // unused (void) err; // unused
#endif #endif
} }
catch (::jvmaccess::VirtualMachine::AttachGuard::CreationException &) catch (const ::jvmaccess::VirtualMachine::AttachGuard::CreationException &)
{ {
OSL_FAIL( OSL_FAIL(
"[jni_uno bridge error] attaching current thread " "[jni_uno bridge error] attaching current thread "

View File

@@ -615,7 +615,7 @@ JNICALL Java_com_sun_star_bridges_jni_1uno_JNI_1proxy_dispatch_1call(
buf.append( jni.get_stack_trace() ); buf.append( jni.get_stack_trace() );
throw BridgeRuntimeError( buf.makeStringAndClear() ); throw BridgeRuntimeError( buf.makeStringAndClear() );
} }
catch (BridgeRuntimeError & err) catch (const BridgeRuntimeError & err)
{ {
OUStringBuffer buf( 128 ); OUStringBuffer buf( 128 );
buf.appendAscii( buf.appendAscii(
@@ -636,7 +636,7 @@ JNICALL Java_com_sun_star_bridges_jni_1uno_JNI_1proxy_dispatch_1call(
} }
return 0; return 0;
} }
catch (::jvmaccess::VirtualMachine::AttachGuard::CreationException &) catch (const ::jvmaccess::VirtualMachine::AttachGuard::CreationException &)
{ {
OString cstr_msg( OString cstr_msg(
OString( RTL_CONSTASCII_STRINGPARAM( OString( RTL_CONSTASCII_STRINGPARAM(

View File

@@ -84,7 +84,7 @@ static void SAL_CALL executeRequest(void * data) {
env->CallObjectMethod(job->job, job->pool->execute); env->CallObjectMethod(job->job, job->pool->execute);
env->DeleteGlobalRef(job->job); env->DeleteGlobalRef(job->job);
delete job; delete job;
} catch (jvmaccess::VirtualMachine::AttachGuard::CreationException &) { } catch (const jvmaccess::VirtualMachine::AttachGuard::CreationException &) {
//TODO: DeleteGlobalRef(job->job) //TODO: DeleteGlobalRef(job->job)
delete job; delete job;
} }
@@ -141,7 +141,7 @@ Java_com_sun_star_lib_uno_environments_remote_NativeThreadPool_create(
return reinterpret_cast< jlong >(new Pool( return reinterpret_cast< jlong >(new Pool(
new jvmaccess::VirtualMachine(vm, env->GetVersion(), false, env), new jvmaccess::VirtualMachine(vm, env->GetVersion(), false, env),
execute, uno_threadpool_create())); execute, uno_threadpool_create()));
} catch (std::bad_alloc) { } catch (const std::bad_alloc &) {
throwOutOfMemory(env); throwOutOfMemory(env);
return 0; return 0;
} }

View File

@@ -89,7 +89,7 @@ namespace dxcanvas
else else
maMaxTextureSize.reset(); maMaxTextureSize.reset();
} }
catch( uno::Exception& ) catch( const uno::Exception& )
{ {
OSL_FAIL( rtl::OUStringToOString( OSL_FAIL( rtl::OUStringToOString(
comphelper::anyToString( cppu::getCaughtException() ), comphelper::anyToString( cppu::getCaughtException() ),
@@ -130,7 +130,7 @@ namespace dxcanvas
aValue[0] <<= aValues; aValue[0] <<= aValues;
PutProperties( aName, aValue ); PutProperties( aName, aValue );
} }
catch( uno::Exception& ) catch( const uno::Exception& )
{ {
OSL_FAIL( rtl::OUStringToOString( OSL_FAIL( rtl::OUStringToOString(
comphelper::anyToString( cppu::getCaughtException() ), comphelper::anyToString( cppu::getCaughtException() ),

View File

@@ -203,11 +203,11 @@ CanvasFactory::CanvasFactory( Reference<XComponentContext> const & xContext ) :
++pCurr; ++pCurr;
} }
} }
catch (RuntimeException &) catch (const RuntimeException &)
{ {
throw; throw;
} }
catch (Exception&) catch (const Exception&)
{ {
} }
@@ -290,11 +290,11 @@ Reference<XInterface> CanvasFactory::use(
return m_xContext->getServiceManager()->createInstanceWithArgumentsAndContext( return m_xContext->getServiceManager()->createInstanceWithArgumentsAndContext(
serviceName, args, xContext); serviceName, args, xContext);
} }
catch (RuntimeException &) catch (const RuntimeException &)
{ {
throw; throw;
} }
catch (Exception &) catch (const Exception &)
{ {
return Reference<XInterface>(); return Reference<XInterface>();
} }

View File

@@ -916,7 +916,7 @@ namespace canvas
o_rxParams[ 1 ] = uno::makeAny( xPropSet->getPropertyValue( o_rxParams[ 1 ] = uno::makeAny( xPropSet->getPropertyValue(
::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("DeviceHandle") ) ) ); ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("DeviceHandle") ) ) );
} }
catch( uno::Exception& ) catch( const uno::Exception& )
{ {
// ignore, but return empty sequence // ignore, but return empty sequence
} }

View File

@@ -678,7 +678,7 @@ void DemoApp::Main()
if( xFactory.is() ) if( xFactory.is() )
::comphelper::setProcessServiceFactory( xFactory ); ::comphelper::setProcessServiceFactory( xFactory );
} }
catch( uno::Exception& ) catch( const uno::Exception& )
{ {
} }