xtd 0.2.0
Loading...
Searching...
No Matches
xtd::runtime::exception_services::exception_dispatch_info Class Referencefinal
Inheritance diagram for xtd::runtime::exception_services::exception_dispatch_info:
xtd::object

Definition

Represents an exception whose state is captured at a certain point in code.

Definition
class exception_dispatch_info final : public xtd::object;
Supports all classes in the xtd class hierarchy and provides low-level services to derived classes....
Definition object.h:42
Represents an exception whose state is captured at a certain point in code.
Definition exception_dispatch_info.h:32
Header
#include <xtd/runtime/exception_services/exception_dispatch_info>
Namespace
xtd::runtime
Library
xtd.core
Remarks
An xtd::runtime::exception_services::exception_dispatch_info object stores the stack trace information that an exception contains at the point where it's captured. The exception can then be thrown at another time and possibly on another thread by calling the xtd::runtime::exception_services::exception_dispatch_info.rethrow method. The exception is thrown as if it had flowed from the point where it was captured to the point where the xtd::runtime::exception_services::exception_dispatch_info::rethrow method is called.
For an example, see Capture exceptions to rethrow later.

Public Properties

bool exception_captured () const noexcept
 Gets a value indicating whether the exception is caught or not.
 
xtd::ptr< xtd::exceptionsource_exception () const noexcept
 Gets the exception that's represented by the current instance.
 
void rethrow ()
 Rethrows the exception that's represented by the current xtd::runtime::exception_services::exception_dispatch_info object, after restoring the state that was saved when the exception was captured.
 
template<typename exception_t >
static exception_dispatch_info capture (const exception_t &source)
 Creates an xtd::runtime::exception_services::exception_dispatch_info object that represents the specified exception at the current point in code.
 
template<typename exception_t >
static void rethrow (const exception_t &source)
 Rehrows the source exception, maintaining the original stack trace information.
 

Public Operators

 operator bool () const noexcept
 Convert to boolean operator.
 

Additional Inherited Members

- Public Member Functions inherited from xtd::object
 object ()=default
 Create a new instance of the ultimate base class object.
 
virtual bool equals (const object &obj) const noexcept
 Determines whether the specified object is equal to the current object.
 
virtual size_t get_hash_code () const noexcept
 Serves as a hash function for a particular type.
 
virtual type_object get_type () const noexcept
 Gets the type of the current instance.
 
template<typename object_t >
xtd::uptr< object_t > memberwise_clone () const
 Creates a shallow copy of the current object.
 
virtual xtd::string to_string () const noexcept
 Returns a xtd::string that represents the current object.
 
- Static Public Member Functions inherited from xtd::object
template<typename object_a_t , typename object_b_t >
static bool equals (const object_a_t &object_a, const object_b_t &object_b) noexcept
 Determines whether the specified object instances are considered equal.
 
template<typename object_a_t , typename object_b_t >
static bool reference_equals (const object_a_t &object_a, const object_b_t &object_b) noexcept
 Determines whether the specified object instances are the same instance.
 

Member Function Documentation

◆ exception_captured()

bool xtd::runtime::exception_services::exception_dispatch_info::exception_captured ( ) const
inlinenoexcept

Gets a value indicating whether the exception is caught or not.

Returns
trueif the exception is captured; otherwise false.

◆ source_exception()

xtd::ptr< xtd::exception > xtd::runtime::exception_services::exception_dispatch_info::source_exception ( ) const
inlinenoexcept

Gets the exception that's represented by the current instance.

Returns
The exception that's represented by the current instance.
Remarks
This property is used by the Task Parallel Library, for example, to combine multiple exceptions in an xtd::aggregate_exception object. It's not intended to be used by application code. Use the xtd::runtime::exception_services::exception_dispatch_info::rethrow method to restore the state of the captured exception and throw it.

◆ capture()

template<typename exception_t >
static exception_dispatch_info xtd::runtime::exception_services::exception_dispatch_info::capture ( const exception_t &  source)
inlinestatic

Creates an xtd::runtime::exception_services::exception_dispatch_info object that represents the specified exception at the current point in code.

Parameters
sourceThe exception whose state is captured, and which is represented by the returned object.
Returns
An object that represents the specified exception at the current point in code.
Remarks
You can use the xtd::runtime::exception_services::exception_dispatch_info object that's returned by this method at another time and possibly on another thread to rethrow the specified exception, as if the exception had flowed from the point where it was captured to the point where it's rethrown.
If the exception is active when it's captured, the current stack trace information that's contained in the exception is stored. If it's inactive, that is, if it has not been thrown, it doesn't have any stack trace information.

◆ rethrow() [1/2]

void xtd::runtime::exception_services::exception_dispatch_info::rethrow ( )
inline

Rethrows the exception that's represented by the current xtd::runtime::exception_services::exception_dispatch_info object, after restoring the state that was saved when the exception was captured.

◆ rethrow() [2/2]

template<typename exception_t >
static void xtd::runtime::exception_services::exception_dispatch_info::rethrow ( const exception_t &  source)
inlinestatic

Rehrows the source exception, maintaining the original stack trace information.

◆ operator bool()

xtd::runtime::exception_services::exception_dispatch_info::operator bool ( ) const
inlineexplicitnoexcept

Convert to boolean operator.

Returns
true if exception is captured; otherwise false.

The documentation for this class was generated from the following file: