xtd 0.2.0
Loading...
Searching...
No Matches
xtd::system_exception Class Reference
Inheritance diagram for xtd::system_exception:
xtd::exception xtd::object 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

The exception that is thrown when a method call is invalid for the object's current state.

Namespace
xtd
Library
xtd.core
Examples
The following example demonstrates how to throw and catch an system_exception.
#include <xtd/console>
#include <xtd/guid>
using namespace xtd;
long create_handle() {
return reinterpret_cast<long>(new guid());
}
void destroy_handle(long handle) {
if (handle == 0) throw system_exception("The handle is null");
delete reinterpret_cast<object*>(handle);
}
auto main() -> int {
try {
auto handle = 0l;
// The following line is commented out so that the exception is generated.
//handle = create_handle();
destroy_handle(handle);
} catch (const system_exception& e) {
console::write_line("Exception occured :");
console::write_line("-------------------");
}
}
// This code can produce the following output :
//
// Exception occured :
// -------------------
// xtd::system_exception : The handle is null
// at destroy_handle(long) [0x00004B20] in /|---OMITTED---|/system_exception/src/system_exception.cpp:line 10
// at main [0x00004DD0] in /|---OMITTED---|/system_exception/Debug/system_exception:line 0
static void write_line()
Writes the current line terminator to the standard output stream using the specified format informati...
The exception that is thrown when a method call is invalid for the object's current state.
Definition system_exception.hpp:18
@ l
The L key.
@ e
The E key.
The xtd namespace contains all fundamental classes to access Hardware, Os, System,...
Definition xtd_about_box.hpp:10
Represents a globally unique identifier (GUID). A GUID is a 128-bit integer (16 bytes) that can be us...
Definition guid.hpp:24
Examples
application_and_exception.cpp, barrier.cpp, default_trace_listener.cpp, enum_class_parse.cpp, exception_box.cpp, exception_dialog.cpp, exception_ptr.cpp, file_info.cpp, file_info_move_to.cpp, file_info_replace.cpp, format_exception.cpp, iobservable_iobserver.cpp, ip_address.cpp, lock.cpp, lock_guard.cpp, lock_guard_keyword.cpp, monitor.cpp, parse_boolean.cpp, parse_enum.cpp, parse_enum_class.cpp, parse_enum_struct.cpp, parse_floating_point.cpp, parse_numeric.cpp, stack_frame.cpp, stack_trace_simple.cpp, stopwatch.cpp, and system_exception.cpp.

Public Constructors

 system_exception (const xtd::diagnostics::stack_frame &stack_frame=xtd::diagnostics::stack_frame::current())
 Create a new instance of class xtd::system_exception.
 
 system_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 xtd::system_exception.
 
template<typename exception_t >
 system_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 xtd::system_exception.
 
 system_exception (const xtd::string &message, const std::error_code &error, const xtd::diagnostics::stack_frame &stack_frame=xtd::diagnostics::stack_frame::current())
 Create a new instance of class xtd::system_exception.
 
 system_exception (const xtd::string &message, const xtd::string &help_link, const xtd::diagnostics::stack_frame &stack_frame=xtd::diagnostics::stack_frame::current())
 Create a new instance of class xtd::system_exception.
 
 system_exception (const xtd::string &message, const std::error_code &error, const xtd::string &help_link, const xtd::diagnostics::stack_frame &stack_frame=xtd::diagnostics::stack_frame::current())
 Create a new instance of class xtd::system_exception.
 
 system_exception (const std::exception &inner_exception, const xtd::diagnostics::stack_frame &stack_frame=xtd::diagnostics::stack_frame::current())
 Create a new instance of class xtd::system_exception.
 
 system_exception (const xtd::string &message, const std::exception &inner_exception, const xtd::diagnostics::stack_frame &stack_frame=xtd::diagnostics::stack_frame::current())
 Create a new instance of class xtd::system_exception.
 
 system_exception (const xtd::string &message, const std::exception &inner_exception, const std::error_code &error, const xtd::diagnostics::stack_frame &stack_frame=xtd::diagnostics::stack_frame::current())
 Create a new instance of class xtd::system_exception.
 
 system_exception (const xtd::string &message, const std::exception &inner_exception, const xtd::string &help_link, const xtd::diagnostics::stack_frame &stack_frame=xtd::diagnostics::stack_frame::current())
 Create a new instance of class xtd::system_exception.
 
 system_exception (const xtd::string &message, const std::exception &inner_exception, const std::error_code &error, const xtd::string &help_link, const xtd::diagnostics::stack_frame &stack_frame=xtd::diagnostics::stack_frame::current())
 Create a new instance of class xtd::system_exception.
 

Public Properties

virtual const xtd::stringfile_path () const noexcept
 Gets file path where exception occurred.
 
virtual xtd::size line_number () const noexcept
 Gets Line number where the exception occurred.
 
virtual const xtd::stringmember_name () const noexcept
 Gets file member where exception occurred.
 
virtual const xtd::stringname () const noexcept
 Gets full class name the exception.
 

Additional Inherited Members

- Public Types inherited from xtd::exception
using exception_ref = xtd::optional< std::reference_wrapper< const xtd::exception > >
 Optional reference wrapper on std::exception.
 
- Public Member Functions inherited from xtd::exception
 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.
 
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.
 
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 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::exception
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.
 
- 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.
 

Constructor & Destructor Documentation

◆ system_exception() [1/11]

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

Create a new instance of class xtd::system_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.

◆ system_exception() [2/11]

xtd::system_exception::system_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 xtd::system_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().

◆ system_exception() [3/11]

template<typename exception_t >
xtd::system_exception::system_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 xtd::system_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().

◆ system_exception() [4/11]

xtd::system_exception::system_exception ( const xtd::string message,
const std::error_code &  error,
const xtd::diagnostics::stack_frame stack_frame = xtd::diagnostics::stack_frame::current() 
)
explicit

Create a new instance of class xtd::system_exception.

Parameters
messageMessage string associate to the exception.
errorError code 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().
Deprecated:
Use xtd::system_exception (const xtd::string& message, const xtd::diagnostics::stack_frame& stack_frame) and manually set the property xtd::exception::error_code - Will be removed in version 0.4.0.

◆ system_exception() [5/11]

xtd::system_exception::system_exception ( const xtd::string message,
const xtd::string help_link,
const xtd::diagnostics::stack_frame stack_frame = xtd::diagnostics::stack_frame::current() 
)
explicit

Create a new instance of class xtd::system_exception.

Parameters
messageMessage string associate to the exception.
help_linkHelp link 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().
Deprecated:
Use xtd::system_exception (const xtd::string& message, const xtd::diagnostics::stack_frame& stack_frame) and manually set the property xtd::exception::help_link - Will be removed in version 0.4.0.

◆ system_exception() [6/11]

xtd::system_exception::system_exception ( const xtd::string message,
const std::error_code &  error,
const xtd::string help_link,
const xtd::diagnostics::stack_frame stack_frame = xtd::diagnostics::stack_frame::current() 
)
explicit

Create a new instance of class xtd::system_exception.

Parameters
messageMessage string associate to the exception.
errorError code associate to the exception.
help_linkHelp link 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().
Deprecated:
Use xtd::system_exception (const xtd::string& message, const xtd::diagnostics::stack_frame& stack_frame) and manually set the properties xtd::exception::error_code and xtd::exception::help_link - Will be removed in version 0.4.0.

◆ system_exception() [7/11]

xtd::system_exception::system_exception ( const std::exception &  inner_exception,
const xtd::diagnostics::stack_frame stack_frame = xtd::diagnostics::stack_frame::current() 
)
explicit

Create a new instance of class xtd::system_exception.

Parameters
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().
Remarks
Message is set with the default message associate to the exception.
Deprecated:
Use xtd::system_exception (const xtd::string& message, const exception_t& inner_exception, const xtd::diagnostics::stack_frame& stack_frame) - Will be removed in version 0.4.0.

◆ system_exception() [8/11]

xtd::system_exception::system_exception ( const xtd::string message,
const std::exception &  inner_exception,
const xtd::diagnostics::stack_frame stack_frame = xtd::diagnostics::stack_frame::current() 
)
explicit

Create a new instance of class xtd::system_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().
Deprecated:
Use xtd::system_exception (const xtd::string& message, const exception_t& inner_exception, const xtd::diagnostics::stack_frame& stack_frame) - Will be removed in version 0.4.0.

◆ system_exception() [9/11]

xtd::system_exception::system_exception ( const xtd::string message,
const std::exception &  inner_exception,
const std::error_code &  error,
const xtd::diagnostics::stack_frame stack_frame = xtd::diagnostics::stack_frame::current() 
)
explicit

Create a new instance of class xtd::system_exception.

Parameters
messageMessage string associate to the exception.
inner_exceptionThe exception that is the cause of the current exception.
errorError code 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().
Deprecated:
Use xtd::system_exception (const xtd::string& message, const exception_t& inner_exception, const xtd::diagnostics::stack_frame& stack_frame) and manually set the property xtd::exception::error_code - Will be removed in version 0.4.0.

◆ system_exception() [10/11]

xtd::system_exception::system_exception ( const xtd::string message,
const std::exception &  inner_exception,
const xtd::string help_link,
const xtd::diagnostics::stack_frame stack_frame = xtd::diagnostics::stack_frame::current() 
)
explicit

Create a new instance of class xtd::system_exception.

Parameters
messageMessage string associate to the exception.
inner_exceptionThe exception that is the cause of the current exception.
help_linkHelp link 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().
Deprecated:
Use xtd::system_exception (const xtd::string& message, const exception_t& inner_exception, const xtd::diagnostics::stack_frame& stack_frame) and manually set the property xtd::exception::help_link - Will be removed in version 0.4.0.

◆ system_exception() [11/11]

xtd::system_exception::system_exception ( const xtd::string message,
const std::exception &  inner_exception,
const std::error_code &  error,
const xtd::string help_link,
const xtd::diagnostics::stack_frame stack_frame = xtd::diagnostics::stack_frame::current() 
)
explicit

Create a new instance of class xtd::system_exception.

Parameters
messageMessage string associate to the exception.
inner_exceptionThe exception that is the cause of the current exception.
errorError code associate to the exception.
help_linkHelp link 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().
Deprecated:
Use xtd::system_exception (const xtd::string& message, const exception_t& inner_exception, const xtd::diagnostics::stack_frame& stack_frame) and manually set the properties xtd::exception::error_code and xtd::exception::help_link - Will be removed in version 0.4.0.

Member Function Documentation

◆ file_path()

virtual const xtd::string & xtd::system_exception::file_path ( ) const
virtualnoexcept

Gets file path where exception occurred.

Returns
A string represent file path where exception occurred
Deprecated:
Replaced by xtd::exception::get_last_stack_frame().get_file_name - Will be removed in version 0.4.0.

◆ line_number()

virtual xtd::size xtd::system_exception::line_number ( ) const
virtualnoexcept

Gets Line number where the exception occurred.

Returns
the line number where exception occurred
Deprecated:
Replaced by xtd::exception::get_last_stack_frame().get_file_line_number - Will be removed in version 0.4.0.

◆ member_name()

virtual const xtd::string & xtd::system_exception::member_name ( ) const
virtualnoexcept

Gets file member where exception occurred.

Returns
A string represent member name where exception occurred
Deprecated:
Replaced by xtd::exception::get_last_stack_frame().get_method - Will be removed in version 0.4.0.

◆ name()

virtual const xtd::string & xtd::system_exception::name ( ) const
virtualnoexcept

Gets full class name the exception.

Returns
A string represent a full class name of the exception
Deprecated:
Replaced by xtd::exception::get_type().full_name() - Will be removed in version 0.4.0.

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