2010-10-27 12:30:13 +01:00
|
|
|
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
2012-07-11 09:51:50 +01:00
|
|
|
/*
|
|
|
|
* This file is part of the LibreOffice project.
|
|
|
|
*
|
|
|
|
* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
|
|
|
*
|
|
|
|
* This file incorporates work covered by the following license notice:
|
|
|
|
*
|
|
|
|
* 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 .
|
|
|
|
*/
|
2013-10-23 19:15:52 +02:00
|
|
|
#ifndef INCLUDED_TOOLS_DIAGNOSE_EX_H
|
|
|
|
#define INCLUDED_TOOLS_DIAGNOSE_EX_H
|
2007-04-11 19:10:36 +00:00
|
|
|
|
2008-06-24 10:57:11 +00:00
|
|
|
#include <osl/diagnose.h>
|
|
|
|
#include <rtl/ustring.hxx>
|
|
|
|
|
|
|
|
#include <com/sun/star/uno/RuntimeException.hpp>
|
|
|
|
#include <com/sun/star/lang/IllegalArgumentException.hpp>
|
|
|
|
|
|
|
|
#include <boost/current_function.hpp>
|
|
|
|
|
2015-09-08 18:26:02 +03:00
|
|
|
#include <tools/toolsdllapi.h>
|
2007-04-11 19:10:36 +00:00
|
|
|
|
2015-09-08 18:26:02 +03:00
|
|
|
TOOLS_DLLPUBLIC void DbgUnhandledException(const ::com::sun::star::uno::Any& caughtException, const char* currentFunction, const char* fileAndLineNo);
|
2013-05-21 08:40:07 +02:00
|
|
|
|
2007-04-11 19:10:36 +00:00
|
|
|
#if OSL_DEBUG_LEVEL > 0
|
2011-10-07 21:09:41 +02:00
|
|
|
#include <com/sun/star/configuration/CorruptedConfigurationException.hpp>
|
2007-04-11 19:10:36 +00:00
|
|
|
#include <cppuhelper/exc_hlp.hxx>
|
|
|
|
#include <osl/diagnose.h>
|
|
|
|
#include <osl/thread.h>
|
|
|
|
#include <boost/current_function.hpp>
|
2013-05-21 08:40:07 +02:00
|
|
|
|
2007-04-11 19:10:36 +00:00
|
|
|
/** reports a caught UNO exception via OSL diagnostics
|
|
|
|
|
|
|
|
Note that whenever you use this, it might be an indicator that your error
|
|
|
|
handling is not correct ....
|
|
|
|
*/
|
|
|
|
#define DBG_UNHANDLED_EXCEPTION() \
|
2013-06-07 14:44:48 +02:00
|
|
|
DbgUnhandledException( ::cppu::getCaughtException(), BOOST_CURRENT_FUNCTION, SAL_DETAIL_WHERE);
|
2007-04-11 19:10:36 +00:00
|
|
|
|
|
|
|
#else // OSL_DEBUG_LEVEL
|
|
|
|
#define DBG_UNHANDLED_EXCEPTION()
|
|
|
|
#endif // OSL_DEBUG_LEVEL
|
|
|
|
|
2008-06-24 10:57:11 +00:00
|
|
|
/** This macro asserts the given condition (in debug mode), and throws
|
|
|
|
an IllegalArgumentException afterwards.
|
|
|
|
*/
|
|
|
|
#define ENSURE_ARG_OR_THROW(c, m) if( !(c) ) { \
|
|
|
|
OSL_ENSURE(c, m); \
|
|
|
|
throw ::com::sun::star::lang::IllegalArgumentException( \
|
2014-12-18 13:36:33 +01:00
|
|
|
OUStringLiteral(BOOST_CURRENT_FUNCTION) \
|
|
|
|
+ ",\n" m, \
|
2008-06-24 10:57:11 +00:00
|
|
|
::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >(), \
|
|
|
|
0 ); }
|
|
|
|
#define ENSURE_ARG_OR_THROW2(c, m, ifc, arg) if( !(c) ) { \
|
|
|
|
OSL_ENSURE(c, m); \
|
|
|
|
throw ::com::sun::star::lang::IllegalArgumentException( \
|
2014-12-18 13:36:33 +01:00
|
|
|
OUStringLiteral(BOOST_CURRENT_FUNCTION) \
|
|
|
|
+ ",\n" m, \
|
2008-06-24 10:57:11 +00:00
|
|
|
ifc, \
|
|
|
|
arg ); }
|
|
|
|
|
|
|
|
/** This macro asserts the given condition (in debug mode), and throws
|
|
|
|
an RuntimeException afterwards.
|
|
|
|
*/
|
2010-11-19 12:00:05 +00:00
|
|
|
#define ENSURE_OR_THROW(c, m) \
|
|
|
|
if( !(c) ){ \
|
|
|
|
OSL_ENSURE(c, m); \
|
|
|
|
throw ::com::sun::star::uno::RuntimeException( \
|
2014-12-18 13:36:33 +01:00
|
|
|
OUStringLiteral(BOOST_CURRENT_FUNCTION) + ",\n" m, \
|
2010-11-19 12:00:05 +00:00
|
|
|
::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >() ); }
|
|
|
|
|
|
|
|
#define ENSURE_OR_THROW2(c, m, ifc) \
|
|
|
|
if( !(c) ) { \
|
|
|
|
OSL_ENSURE(c, m); \
|
|
|
|
throw ::com::sun::star::uno::RuntimeException( \
|
2014-12-18 13:36:33 +01:00
|
|
|
OUStringLiteral(BOOST_CURRENT_FUNCTION) + ",\n" m, \
|
2010-11-19 12:00:05 +00:00
|
|
|
ifc ); }
|
2008-06-24 10:57:11 +00:00
|
|
|
|
|
|
|
/** This macro asserts the given condition (in debug mode), and
|
2010-01-29 08:49:42 +01:00
|
|
|
returns the given value afterwards.
|
2008-06-24 10:57:11 +00:00
|
|
|
*/
|
2010-01-29 08:49:42 +01:00
|
|
|
#define ENSURE_OR_RETURN(c, m, r) if( !(c) ) { \
|
2008-06-24 10:57:11 +00:00
|
|
|
OSL_ENSURE(c, m); \
|
2010-01-29 08:49:42 +01:00
|
|
|
return r; }
|
|
|
|
|
|
|
|
/** This macro asserts the given condition (in debug mode), and
|
|
|
|
returns false afterwards.
|
|
|
|
*/
|
|
|
|
#define ENSURE_OR_RETURN_FALSE(c, m) \
|
|
|
|
ENSURE_OR_RETURN(c, m, false)
|
2008-06-24 10:57:11 +00:00
|
|
|
|
2010-02-12 10:45:01 +01:00
|
|
|
/** This macro asserts the given condition (in debug mode), and
|
|
|
|
returns afterwards, without return value "void".
|
|
|
|
*/
|
|
|
|
#define ENSURE_OR_RETURN_VOID( c, m ) \
|
|
|
|
if( !(c) ) \
|
|
|
|
{ \
|
|
|
|
OSL_ENSURE( c, m ); \
|
|
|
|
return; \
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2008-06-24 10:57:11 +00:00
|
|
|
|
2010-02-12 10:45:01 +01:00
|
|
|
/** This macro asserts the given condition (in debug mode), and
|
|
|
|
returns afterwards, without return value "void".
|
|
|
|
*/
|
|
|
|
#define ENSURE_OR_RETURN_VOID( c, m ) \
|
|
|
|
if( !(c) ) \
|
|
|
|
{ \
|
|
|
|
OSL_ENSURE( c, m ); \
|
|
|
|
return; \
|
|
|
|
}
|
|
|
|
|
2012-08-13 23:14:08 +02:00
|
|
|
#endif
|
2010-10-27 12:30:13 +01:00
|
|
|
|
|
|
|
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|