errorprint.h revision c10e4369d16f6b417e816db46d10c2883ac25133
/** @file
* MS COM / XPCOM Abstraction Layer:
* Error printing macros using shared functions defined in shared glue code.
* Use these CHECK_* macros for efficient error checking around calling COM methods.
*/
/*
* Copyright (C) 2009 Oracle Corporation
*
* This file is part of VirtualBox Open Source Edition (OSE), as
* available from http://www.virtualbox.org. This file is free software;
* General Public License (GPL) as published by the Free Software
* Foundation, in version 2 as it comes in the "COPYING" file of the
* VirtualBox OSE distribution. VirtualBox OSE is distributed in the
* hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
*
* The contents of this file may alternatively be used under the terms
* of the Common Development and Distribution License Version 1.0
* (CDDL) only, as it comes in the "COPYING.CDDL" file of the
* VirtualBox OSE distribution, in which case the provisions of the
* CDDL are applicable instead of those of the GPL.
*
* You may elect to license modified versions of this file under the
* terms and conditions of either the GPL or the CDDL or both.
*/
#ifndef ___VBox_com_errorprint_h
#define ___VBox_com_errorprint_h
{
// shared prototypes; these are defined in shared glue code and are
// compiled only once for all front-ends
const char *pcszContext,
const char *pcszSourceFile,
const char *pcszContext,
const char *pcszSourceFile,
/**
* Calls the given method of the given interface and then checks if the return
* value (COM result code) indicates a failure. If so, prints the failed
* query the extended error information on the current thread (using
* com::ErrorInfo) if the interface reports that it supports error information.
*
* Used by command line tools or for debugging and assumes the |HRESULT rc|
* variable is accessible for assigning in the current scope.
*/
do { \
} while (0)
/**
* Same as CHECK_ERROR except that it also executes the statement |stmt| on
* failure.
*/
do { \
{ \
stmt; \
} \
} while (0)
/**
* Same as CHECK_ERROR_STMT except that it uses an internal variable |hrcCheck|
* for holding the result.
*/
do { \
{ \
stmt; \
} \
} while (0)
/**
* Does the same as CHECK_ERROR(), but executes the |break| statement on
* failure.
*/
#ifdef __GNUC__
({ \
{ \
break; \
} \
})
#else
if (1) \
{ \
{ \
break; \
} \
} \
else do {} while (0)
#endif
/**
* Does the same as CHECK_ERROR(), but executes the |return ret| statement on
* failure.
*/
do { \
{ \
return (ret); \
} \
} while (0)
/**
* Does the same as CHECK_ERROR(), but returns @a ret on failure.
*
* Unlike CHECK_ERROR and CHECK_ERROR_RET, this macro does not presuppose a
* |rc| variable but instead employs a local variable |hrcCheck| in its own
* scope. This |hrcCheck| variable can be referenced by the @a rcRet
* parameter.
*
* @param iface The interface pointer (can be a smart pointer object).
* @param method The method to invoke together with the parameters.
* @param rcRet What to return on failure. Use |hrcCheck| to return
* the status code of the method call.
*/
do { \
{ \
return (rcRet); \
} \
} while (0)
/**
* Check the progress object for an error and if there is one print out the
* extended error information.
*/
#define CHECK_PROGRESS_ERROR(progress) \
do { \
} while (0)
/**
* Does the same as CHECK_PROGRESS_ERROR(), but executes the |return ret| statement on
* failure.
*/
do { \
{ \
return (ret); \
} \
} while (0)
/**
* Asserts the given expression is true. When the expression is false, prints
*/
do { \
if (!(expr)) \
{ \
} \
} while (0)
#endif
/**
* Does the same as ASSERT(), but executes the |return ret| statement if the
* expression to assert is false;
*/
/**
* Does the same as ASSERT(), but executes the |break| statement if the
* expression to assert is false;
*/
} /* namespace com */