ADTF
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
exception_handling.h File Reference

Copyright © Audi Electronics Venture GmbH. More...

Go to the source code of this file.

Namespaces

namespace  adtf
 Namespace for entire ADTF SDK.
 
namespace  adtf::ucom
 Namespace for the ADTF uCOM3 SDK.
 
namespace  adtf::ucom::kiwi
 Namespace for all functionality provided since v3.10.
 

Macros

#define ADTF_UCOM_ANNOTATE_RESULT(_result)
 for internal use
 
#define ADTF_UCOM_COMPOSED_RESULT(_result, ...)
 for internal use
 
#define THROW_ERROR_DESC(_code, ...)
 throws a tResult exception
 
#define THROW_IF_FAILED(s)
 throws if the expression returns a failed tResult
 
#define THROW_IF_FAILED_DESC(s, ...)
 throws if the expression returns a failed tResult and ammends the error message.
 
#define RETURN_CURRENT_EXCEPTION()
 returns the current exception as a tResult, use it in a catch block.
 
#define RETURN_CURRENT_EXCEPTION_DESC(...)
 returns the current exception as a tResult and ammends the error message.
 
#define RETURN_IF_THROWS(s)
 if the expression throws an exception, returns a tResult containing the exception information.
 
#define RETURN_IF_THROWS_DESC(s, ...)
 if the expression throws an exception, returns a tResult containing the exception information and ammends the error message.
 
#define RETURN_IF_FAILED(s)
 returns if the expression returns a failed tResult or throws an exception.
 
#define RETURN_IF_FAILED_DESC(s, ...)
 returns if the expression returns a failed tResult and ammends the error message.
 

Functions

std::string nested_exceptions_to_string (const std::exception &error)
 Formats nested std::exceptions into a string, line by line.
 
void format_nested_exception (const std::exception &error, std::ostream &stream, bool add_line_break=false)
 
tResult annotate_result (const tResult &oOriginal, const char *strFile, int nLine, const char *strFunction, const tChar *strDescription="")
 
tResult current_exception_to_result (const char *file, size_t line, const char *function)
 
std::string current_exception_to_string ()
 Trys to format the current exception into a string.
 
tResult current_exception_to_result ()
 Converts the current exception object into a tResult.
 
std::string nested_exceptions_to_string (const std::exception &error)
 Formats nested std::exceptions into a string, line by line.
 
std::string current_exception_to_string ()
 Trys to format the current exception into a string.
 
tResult current_exception_to_result ()
 Converts the current exception object into a tResult.
 

Detailed Description

Copyright © Audi Electronics Venture GmbH.

All rights reserved

Definition in file ucom3/include/adtfucom3/exception_handling.h.

Macro Definition Documentation

◆ ADTF_UCOM_ANNOTATE_RESULT

#define ADTF_UCOM_ANNOTATE_RESULT ( _result)
Value:
adtf::ucom::kiwi::detail::annotate_result(_result, __FILE__, __LINE__, __FUNC__)

for internal use

Definition at line 169 of file ucom3/include/adtfucom3/exception_handling.h.

◆ ADTF_UCOM_COMPOSED_RESULT

#define ADTF_UCOM_COMPOSED_RESULT ( _result,
... )
Value:
adtf::ucom::kiwi::detail::annotate_result(_result, __FILE__, __LINE__, __FUNC__, adtf::util::cString::Format(__VA_ARGS__).GetPtr())

for internal use

Definition at line 172 of file ucom3/include/adtfucom3/exception_handling.h.

◆ RETURN_CURRENT_EXCEPTION

#define RETURN_CURRENT_EXCEPTION ( )
Value:
return adtf::ucom::kiwi::detail::current_exception_to_result(__FILE__, __LINE__, __FUNC__)

returns the current exception as a tResult, use it in a catch block.

Definition at line 182 of file ucom3/include/adtfucom3/exception_handling.h.

◆ RETURN_CURRENT_EXCEPTION_DESC

#define RETURN_CURRENT_EXCEPTION_DESC ( ...)
Value:
return ADTF_UCOM_COMPOSED_RESULT(adtf::ucom::kiwi::detail::current_exception_to_result(__FILE__, __LINE__, __FUNC__), __VA_ARGS__)
#define ADTF_UCOM_COMPOSED_RESULT(_result,...)
for internal use

returns the current exception as a tResult and ammends the error message.

Definition at line 184 of file ucom3/include/adtfucom3/exception_handling.h.

◆ RETURN_IF_FAILED

#define RETURN_IF_FAILED ( s)
Value:
{ try { tResult _errcode(s); if ( _errcode.IsFailed() ) { return ADTF_UCOM_ANNOTATE_RESULT(_errcode); } } catch (...) { RETURN_CURRENT_EXCEPTION(); } }
A_UTILS_NS::cResult tResult
For backwards compatibility and to bring latest version into scope.
#define ADTF_UCOM_ANNOTATE_RESULT(_result)
for internal use
#define RETURN_CURRENT_EXCEPTION()
returns the current exception as a tResult, use it in a catch block.

returns if the expression returns a failed tResult or throws an exception.

Definition at line 196 of file ucom3/include/adtfucom3/exception_handling.h.

◆ RETURN_IF_FAILED_DESC

#define RETURN_IF_FAILED_DESC ( s,
... )
Value:
{ try { tResult _errcode(s); if ( _errcode.IsFailed() ) { return ADTF_UCOM_COMPOSED_RESULT(_errcode, __VA_ARGS__); } } catch (...) { RETURN_CURRENT_EXCEPTION_DESC(__VA_ARGS__); } }
#define RETURN_CURRENT_EXCEPTION_DESC(...)
returns the current exception as a tResult and ammends the error message.

returns if the expression returns a failed tResult and ammends the error message.

Definition at line 202 of file ucom3/include/adtfucom3/exception_handling.h.

◆ RETURN_IF_THROWS

◆ RETURN_IF_THROWS_DESC

#define RETURN_IF_THROWS_DESC ( s,
... )
Value:
{ try { (s); } catch(...) { RETURN_CURRENT_EXCEPTION_DESC(__VA_ARGS__); } }

if the expression throws an exception, returns a tResult containing the exception information and ammends the error message.

Definition at line 189 of file ucom3/include/adtfucom3/exception_handling.h.

◆ THROW_ERROR_DESC

◆ THROW_IF_FAILED

◆ THROW_IF_FAILED_DESC

#define THROW_IF_FAILED_DESC ( s,
... )
Value:
{ tResult _errcode(s); if ( _errcode.IsFailed() ) { throw ADTF_UCOM_COMPOSED_RESULT(_errcode, __VA_ARGS__); } }

throws if the expression returns a failed tResult and ammends the error message.

Definition at line 179 of file ucom3/include/adtfucom3/exception_handling.h.

Referenced by interface_client< Interface >::Get().

Function Documentation

◆ annotate_result()

tResult annotate_result ( const tResult & oOriginal,
const char * strFile,
int nLine,
const char * strFunction,
const tChar * strDescription = "" )
inline

Definition at line 47 of file ucom3/include/adtfucom3/exception_handling.h.

◆ current_exception_to_result()

tResult current_exception_to_result ( const char * file,
size_t line,
const char * function )
inline

Definition at line 68 of file ucom3/include/adtfucom3/exception_handling.h.

◆ format_nested_exception()

void format_nested_exception ( const std::exception & error,
std::ostream & stream,
bool add_line_break = false )
inline

Definition at line 26 of file ucom3/include/adtfucom3/exception_handling.h.