xtd 0.2.0
Loading...
Searching...
No Matches
xtd::exception Class Reference
Inheritance diagram for xtd::exception:
xtd::object xtd::system_exception xtd::tunit::abort_error xtd::tunit::assert_error xtd::tunit::ignore_error xtd::access_violation_exception xtd::argument_exception xtd::arithmetic_exception xtd::collections::generic::key_not_found_exception xtd::collections::key_not_found_exception xtd::domain_exception xtd::format_exception xtd::index_out_of_range_exception xtd::interrupt_exception xtd::invalid_cast_exception xtd::invalid_operation_exception xtd::invalid_program_exception xtd::io::io_exception xtd::length_exception xtd::net::sockets::socket_exception xtd::not_implemented_exception xtd::not_supported_exception xtd::null_pointer_exception xtd::object_closed_exception xtd::operation_canceled_exception xtd::out_of_memory_exception xtd::rank_exception xtd::security::security_exception xtd::software_termination_exception xtd::threading::abandoned_mutex_exception xtd::threading::barrier_post_phase_exception xtd::threading::lock_recursion_exception xtd::threading::semaphore_full_exception xtd::threading::synchronization_lock_exception xtd::threading::thread_abort_exception xtd::threading::thread_interrupted_exception xtd::threading::thread_state_exception xtd::threading::wait_handle_cannot_be_opened_exception xtd::time_zone_not_found_exception xtd::timeout_exception xtd::unauthorized_access_exception xtd::uri_template_match_exception xtd::xml_syntax_exception

Definition

Defines the base class for predefined exceptions in the xtd namespace.

Namespace
xtd
Library
xtd.core
Examples
user_defined_exception.cpp.

Public Aliases

using exception_ref = xtd::optional< std::reference_wrapper< const xtd::exception > >
 Optional reference wrapper on std::exception.
 

Public Constructors

 exception (const xtd::diagnostics::stack_frame &stack_frame=xtd::diagnostics::stack_frame::current())
 Create a new instance of class exception.
 
 exception (const xtd::optional< xtd::string > &message, const xtd::diagnostics::stack_frame &stack_frame=xtd::diagnostics::stack_frame::current())
 Create a new instance of class exception.
 
template<typename exception_t >
 exception (const xtd::optional< xtd::string > &message, const exception_t &inner_exception, const xtd::diagnostics::stack_frame &stack_frame=xtd::diagnostics::stack_frame::current())
 Create a new instance of class exception.
 

Public Properties

virtual const xtd::stringhelp_link () const noexcept
 Gets a link to the help file associated with this exception.
 
virtual void help_link (const xtd::string &value) noexcept
 Sets a link to the help file associated with this exception.
 
virtual int32 h_result () const noexcept
 Gets HRESULT, a coded numerical value that is assigned to a specific exception.
 
virtual void h_result (int32 value) noexcept
 Sets HRESULT, a coded numerical value that is assigned to a specific exception.
 
virtual const std::error_code & error_code () const noexcept
 Gets error associate to the exception.
 
virtual void error_code (const std::error_code &value) noexcept
 Sets error associate to the exception.
 
virtual exception_ref inner_exception () const noexcept
 Gets the exception instance that caused the current exception.
 
virtual const xtd::stringmessage () const noexcept
 Gets message associate to the exception.
 
virtual const xtd::stringsource () const noexcept
 Gets the name of the application or the object that causes the error.
 
virtual void source (const xtd::string &value) noexcept
 Sets the name of the application or the object that causes the error.
 
virtual xtd::string stack_trace () const noexcept
 Gets a string representation of the immediate frames on the call stack.
 

Public Methods

virtual const xtd::diagnostics::stack_frameget_last_stack_frame () const noexcept
 Gets the last stack frame where the exception occurred.
 
xtd::string to_string () const noexcept override
 Returns a string that represents the current exception.
 
const char * what () const noexcept override
 Gets message associate to the exception.
 

Public Static Methods

static bool enable_stack_trace () noexcept
 Gets if the generation of the stack trace is enabled.
 
static void enable_stack_trace (bool enable) noexcept
 Sets if the generation of the stack trace is enabled. @paran enable triue if stack trace enabled; otherwhise false.
 

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.
 
- 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 Typedef Documentation

◆ exception_ref

using xtd::exception::exception_ref = xtd::optional<std::reference_wrapper<const xtd::exception> >

Optional reference wrapper on std::exception.

Constructor & Destructor Documentation

◆ exception() [1/3]

xtd::exception::exception ( const xtd::diagnostics::stack_frame stack_frame = xtd::diagnostics::stack_frame::current())
explicit

Create a new instance of class exception.

Parameters
stack_frame(optional) Contains current stack frame about member name, file path and line number in the file where the exception is occurred. Typically xtd::diagnostics::stack_frame::current().
Remarks
Message is set with the default message associate to the exception.

◆ exception() [2/3]

xtd::exception::exception ( const xtd::optional< xtd::string > &  message,
const xtd::diagnostics::stack_frame stack_frame = xtd::diagnostics::stack_frame::current() 
)
explicit

Create a new instance of class exception.

Parameters
messageMessage string associate to the exception.
stack_frame(optional) Contains current stack frame about member name, file path and line number in the file where the exception is occurred. Typically xtd::diagnostics::stack_frame::current().

◆ exception() [3/3]

template<typename exception_t >
xtd::exception::exception ( const xtd::optional< xtd::string > &  message,
const exception_t &  inner_exception,
const xtd::diagnostics::stack_frame stack_frame = xtd::diagnostics::stack_frame::current() 
)
inline

Create a new instance of class exception.

Parameters
messageMessage string associate to the exception.
inner_exceptionThe exception that is the cause of the current exception.
stack_frame(optional) Contains current stack frame about member name, file path and line number in the file where the exception is occurred. Typically xtd::diagnostics::stack_frame::current().

Member Function Documentation

◆ help_link() [1/2]

virtual const xtd::string & xtd::exception::help_link ( ) const
virtualnoexcept

Gets a link to the help file associated with this exception.

Returns
A string represent a link to Help file associated with exception

◆ help_link() [2/2]

virtual void xtd::exception::help_link ( const xtd::string value)
virtualnoexcept

Sets a link to the help file associated with this exception.

Parameters
valueA string represent a link to Help file associated with exception

◆ h_result() [1/2]

virtual int32 xtd::exception::h_result ( ) const
virtualnoexcept

Gets HRESULT, a coded numerical value that is assigned to a specific exception.

Returns
The HRESULT value.

◆ h_result() [2/2]

virtual void xtd::exception::h_result ( int32  value)
virtualnoexcept

Sets HRESULT, a coded numerical value that is assigned to a specific exception.

Parameters
valueThe HRESULT value.

◆ error_code() [1/2]

virtual const std::error_code & xtd::exception::error_code ( ) const
virtualnoexcept

Gets error associate to the exception.

Returns
An error_code represent a Error associate to the exception

◆ error_code() [2/2]

virtual void xtd::exception::error_code ( const std::error_code &  value)
virtualnoexcept

Sets error associate to the exception.

Parameters
valueAn error_code represent a Error associate to the exception

◆ inner_exception()

virtual exception_ref xtd::exception::inner_exception ( ) const
virtualnoexcept

Gets the exception instance that caused the current exception.

Returns
An instance of exception that describes the error that caused the current exception. The inner_exception property returns the same value as was passed into the constructor, or a null reference if the inner exception value was not supplied to the constructor.

◆ message()

virtual const xtd::string & xtd::exception::message ( ) const
virtualnoexcept

Gets message associate to the exception.

Returns
A string represent a massage associate to the exception

Reimplemented in xtd::io::file_not_found_exception.

Examples
barrier.cpp, default_trace_listener.cpp, and file_info_move_to.cpp.

◆ source() [1/2]

virtual const xtd::string & xtd::exception::source ( ) const
virtualnoexcept

Gets the name of the application or the object that causes the error.

Returns
The name of the application or the object that causes the error.
Remarks
If the xtd::exception::source property is not set explicitly, the runtime automatically sets it to the name of the assembly in which the exception originated.

◆ source() [2/2]

virtual void xtd::exception::source ( const xtd::string value)
virtualnoexcept

Sets the name of the application or the object that causes the error.

Returns
The name of the application or the object that causes the error.
Remarks
If the xtd::exception::source property is not set explicitly, the runtime automatically sets it to the name of the assembly in which the exception originated.

◆ stack_trace()

virtual xtd::string xtd::exception::stack_trace ( ) const
virtualnoexcept

Gets a string representation of the immediate frames on the call stack.

Returns
A string that describes the immediate frames of the call stack.
Examples
file_info_move_to.cpp.

◆ get_last_stack_frame()

virtual const xtd::diagnostics::stack_frame & xtd::exception::get_last_stack_frame ( ) const
virtualnoexcept

Gets the last stack frame where the exception occurred.

Returns
The last stack frame where exception occurred

◆ to_string()

xtd::string xtd::exception::to_string ( ) const
overridevirtualnoexcept

Returns a string that represents the current exception.

Returns
A string that represents the current exception.

Reimplemented from xtd::object.

◆ what()

const char * xtd::exception::what ( ) const
overridenoexcept

Gets message associate to the exception.

Returns
A string represent a massage associate to the exception

◆ enable_stack_trace() [1/2]

static bool xtd::exception::enable_stack_trace ( )
staticnoexcept

Gets if the generation of the stack trace is enabled.

Returns
triue if stack trace enabled; otherwhise false.

◆ enable_stack_trace() [2/2]

static void xtd::exception::enable_stack_trace ( bool  enable)
staticnoexcept

Sets if the generation of the stack trace is enabled. @paran enable triue if stack trace enabled; otherwhise false.


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