xtd - Reference Guide  0.1.0
Modern c++17/20 framework to create console, GUI and unit test applications on Windows, macOS, Linux, iOS and android.
Loading...
Searching...
No Matches
Public Member Functions | List of all members
xtd::argument_exception Class Reference

#include <argument_exception.h>

Definition

The exception that is thrown when one of the arguments provided to a method is not valid.

Namespace
xtd
Library
xtd.core
Examples
The following example demonstrates how to throw and catch an argument_exception.
#include <xtd/xtd>
using namespace xtd;
int divide_by_two(int num) {
// If num is an odd number, throw an argument_exception.
if ((num & 1) == 1) throw argument_exception("Number must be even");
// num is even, return half of its value.
return num / 2;
}
int main() {
// argument_exception is not thrown because 10 is an even number.
console::write_line("10 divided by 2 is {0}", divide_by_two(10));
try {
// argument_exception is thrown because 7 is not an even number.
console::write_line("7 divided by 2 is {0}", divide_by_two(7));
} catch (const argument_exception&) {
// Show the user that 7 cannot be divided by 2.
console::write_line("7 is not divided by 2 integrally.");
}
}
// This code can produces the following output :
//
// Exception occured :
// -------------------
// 10 divided by 2 is 5
// 7 is not divided by 2 integrally.
The exception that is thrown when one of the arguments provided to a method is not valid.
Definition: argument_exception.h:19
static void write_line()
Writes the current line terminator to the standard output stream using the specified format informati...
The xtd namespace contains all fundamental classes to access Hardware, Os, System,...
Definition: system_report.h:17
Todo:
add param_name property and constructors param (param_nam is the parameter that cause the exception).

Inherits xtd::system_exception.

Inherited by xtd::argument_null_exception, and xtd::argument_out_of_range_exception.

Public Member Functions

 argument_exception (const std::exception &inner_exception, const xtd::diagnostics::stack_frame &info=xtd::diagnostics::stack_frame::empty())
 Create a new instance of class argument_exception.
 
 argument_exception (const xtd::diagnostics::stack_frame &info=xtd::diagnostics::stack_frame::empty())
 Create a new instance of class argument_exception.
 
 argument_exception (const xtd::ustring &message, const std::error_code &error, const xtd::diagnostics::stack_frame &info=xtd::diagnostics::stack_frame::empty())
 Create a new instance of class argument_exception.
 
 argument_exception (const xtd::ustring &message, const std::error_code &error, const xtd::ustring &help_link, const xtd::diagnostics::stack_frame &info=xtd::diagnostics::stack_frame::empty())
 Create a new instance of class argument_exception.
 
 argument_exception (const xtd::ustring &message, const std::exception &inner_exception, const std::error_code &error, const xtd::diagnostics::stack_frame &info=xtd::diagnostics::stack_frame::empty())
 Create a new instance of class argument_exception.
 
 argument_exception (const xtd::ustring &message, const std::exception &inner_exception, const std::error_code &error, const xtd::ustring &help_link, const xtd::diagnostics::stack_frame &info=xtd::diagnostics::stack_frame::empty())
 Create a new instance of class argument_exception.
 
 argument_exception (const xtd::ustring &message, const std::exception &inner_exception, const xtd::diagnostics::stack_frame &info=xtd::diagnostics::stack_frame::empty())
 Create a new instance of class argument_exception.
 
 argument_exception (const xtd::ustring &message, const std::exception &inner_exception, const xtd::ustring &help_link, const xtd::diagnostics::stack_frame &info=xtd::diagnostics::stack_frame::empty())
 Create a new instance of class argument_exception.
 
 argument_exception (const xtd::ustring &message, const xtd::diagnostics::stack_frame &info=xtd::diagnostics::stack_frame::empty())
 Create a new instance of class argument_exception.
 
 argument_exception (const xtd::ustring &message, const xtd::ustring &help_link, const xtd::diagnostics::stack_frame &info=xtd::diagnostics::stack_frame::empty())
 Create a new instance of class argument_exception.
 
- Public Member Functions inherited from xtd::system_exception
 system_exception (const std::exception &inner_exception, const xtd::diagnostics::stack_frame &information=xtd::diagnostics::stack_frame::empty())
 Create a new instance of class system_exception.
 
 system_exception (const xtd::diagnostics::stack_frame &information=xtd::diagnostics::stack_frame::empty())
 Create a new instance of class system_exception.
 
 system_exception (const xtd::ustring &message, const std::error_code &error, const xtd::diagnostics::stack_frame &information=xtd::diagnostics::stack_frame::empty())
 Create a new instance of class system_exception.
 
 system_exception (const xtd::ustring &message, const std::error_code &error, const xtd::ustring &help_link, const xtd::diagnostics::stack_frame &information=xtd::diagnostics::stack_frame::empty())
 Create a new instance of class system_exception.
 
 system_exception (const xtd::ustring &message, const std::exception &inner_exception, const std::error_code &error, const xtd::diagnostics::stack_frame &information=xtd::diagnostics::stack_frame::empty())
 Create a new instance of class system_exception.
 
 system_exception (const xtd::ustring &message, const std::exception &inner_exception, const std::error_code &error, const xtd::ustring &help_link, const xtd::diagnostics::stack_frame &information=xtd::diagnostics::stack_frame::empty())
 Create a new instance of class system_exception.
 
 system_exception (const xtd::ustring &message, const std::exception &inner_exception, const xtd::diagnostics::stack_frame &information=xtd::diagnostics::stack_frame::empty())
 Create a new instance of class system_exception.
 
 system_exception (const xtd::ustring &message, const std::exception &inner_exception, const xtd::ustring &help_link, const xtd::diagnostics::stack_frame &information=xtd::diagnostics::stack_frame::empty())
 Create a new instance of class system_exception.
 
 system_exception (const xtd::ustring &message, const xtd::diagnostics::stack_frame &information=xtd::diagnostics::stack_frame::empty())
 Create a new instance of class system_exception.
 
 system_exception (const xtd::ustring &message, const xtd::ustring &help_link, const xtd::diagnostics::stack_frame &information=xtd::diagnostics::stack_frame::empty())
 Create a new instance of class system_exception.
 
virtual std::error_code error_code () const noexcept
 Get error associate to the exception.
 
virtual const xtd::ustringfile_path () const noexcept
 Get file path where exception occurred.
 
virtual const xtd::ustringhelp_link () const noexcept
 Gets a link to the help file associated with this exception.
 
virtual exception_ref inner_exception () const noexcept
 Gets the exception instance that caused the current exception.
 
virtual uint32_t line_number () const noexcept
 Get Line number where the exception occurred.
 
virtual const xtd::ustringmember_name () const noexcept
 Get file member where exception occurred.
 
virtual const xtd::ustringmessage () const noexcept
 Get message associate to the exception.
 
virtual const xtd::ustringname () const noexcept
 Get full class name the exception.
 
virtual xtd::ustring stack_trace () const noexcept
 Gets a string representation of the immediate frames on the call stack.
 
xtd::ustring to_string () const noexcept override
 Returns a string that represents the current exception.
 
const char * what () const noexcept override
 Get 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.
 
template<typename object_t >
std::unique_ptr< object_t > memberwise_clone () const
 Gets the type of the current instance.
 
virtual xtd::ustring to_string () const noexcept
 Returns a std::string that represents the current object.
 

Additional Inherited Members

- Public Types inherited from xtd::system_exception
using exception_ref = std::optional< std::reference_wrapper< const std::exception > >
 Optional reference wrapper on std::exception.
 
- Static Public Member Functions inherited from xtd::system_exception
static bool enable_stack_trace ()
 Gets or sets if the generation of the stack trace is enabled.
 
static void enable_stack_trace (bool enable)
 
- Static Public Member Functions inherited from xtd::object
static bool equals (const object &object_a, const object &object_b) noexcept
 Determines whether the specified object instances are considered equal.
 
static bool reference_equals (const object &object_a, const object &object_b) noexcept
 Determines whether the specified object instances are the same instance.
 

Constructor & Destructor Documentation

◆ argument_exception() [1/10]

xtd::argument_exception::argument_exception ( const xtd::diagnostics::stack_frame info = xtd::diagnostics::stack_frame::empty())
inline

Create a new instance of class argument_exception.

Parameters
information(optional) Contains current information about member name, file path and line number in the file where the exception is occurred. Typically current_stack_frame_.
Remarks
Message is set with the default message associate to the exception.

◆ argument_exception() [2/10]

xtd::argument_exception::argument_exception ( const xtd::ustring message,
const xtd::diagnostics::stack_frame info = xtd::diagnostics::stack_frame::empty() 
)
inlineexplicit

Create a new instance of class argument_exception.

Parameters
messageMessage string associate to the exception.
information(optional) Contains current information about member name, file path and line number in the file where the exception is occurred. Typically current_stack_frame_.

◆ argument_exception() [3/10]

xtd::argument_exception::argument_exception ( const xtd::ustring message,
const std::error_code &  error,
const xtd::diagnostics::stack_frame info = xtd::diagnostics::stack_frame::empty() 
)
inlineexplicit

Create a new instance of class argument_exception.

Parameters
messageMessage string associate to the exception.
errorError code associate to the exception.
information(optional) Contains current information about member name, file path and line number in the file where the exception is occurred. Typically current_stack_frame_.

◆ argument_exception() [4/10]

xtd::argument_exception::argument_exception ( const xtd::ustring message,
const xtd::ustring help_link,
const xtd::diagnostics::stack_frame info = xtd::diagnostics::stack_frame::empty() 
)
inlineexplicit

Create a new instance of class argument_exception.

Parameters
messageMessage string associate to the exception.
help_linkHelp link string associate to the exception.
information(optional) Contains current information about member name, file path and line number in the file where the exception is occurred. Typically current_stack_frame_.

◆ argument_exception() [5/10]

xtd::argument_exception::argument_exception ( const xtd::ustring message,
const std::error_code &  error,
const xtd::ustring help_link,
const xtd::diagnostics::stack_frame info = xtd::diagnostics::stack_frame::empty() 
)
inlineexplicit

Create a new instance of class argument_exception.

Parameters
messageMessage string associate to the exception.
errorError code associate to the exception.
help_linkHelp link string associate to the exception.

◆ argument_exception() [6/10]

xtd::argument_exception::argument_exception ( const std::exception &  inner_exception,
const xtd::diagnostics::stack_frame info = xtd::diagnostics::stack_frame::empty() 
)
inline

Create a new instance of class argument_exception.

Parameters
inner_exceptionThe exception that is the cause of the current exception.
information(optional) Contains current information about member name, file path and line number in the file where the exception is occurred. Typically current_stack_frame_.
Remarks
Message is set with the default message associate to the exception.

◆ argument_exception() [7/10]

xtd::argument_exception::argument_exception ( const xtd::ustring message,
const std::exception &  inner_exception,
const xtd::diagnostics::stack_frame info = xtd::diagnostics::stack_frame::empty() 
)
inlineexplicit

Create a new instance of class argument_exception.

Parameters
messageMessage string associate to the exception.
inner_exceptionThe exception that is the cause of the current exception.
information(optional) Contains current information about member name, file path and line number in the file where the exception is occurred. Typically current_stack_frame_.

◆ argument_exception() [8/10]

xtd::argument_exception::argument_exception ( const xtd::ustring message,
const std::exception &  inner_exception,
const std::error_code &  error,
const xtd::diagnostics::stack_frame info = xtd::diagnostics::stack_frame::empty() 
)
inlineexplicit

Create a new instance of class argument_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.
information(optional) Contains current information about member name, file path and line number in the file where the exception is occurred. Typically current_stack_frame_.

◆ argument_exception() [9/10]

xtd::argument_exception::argument_exception ( const xtd::ustring message,
const std::exception &  inner_exception,
const xtd::ustring help_link,
const xtd::diagnostics::stack_frame info = xtd::diagnostics::stack_frame::empty() 
)
inlineexplicit

Create a new instance of class argument_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.
information(optional) Contains current information about member name, file path and line number in the file where the exception is occurred. Typically current_stack_frame_.

◆ argument_exception() [10/10]

xtd::argument_exception::argument_exception ( const xtd::ustring message,
const std::exception &  inner_exception,
const std::error_code &  error,
const xtd::ustring help_link,
const xtd::diagnostics::stack_frame info = xtd::diagnostics::stack_frame::empty() 
)
inlineexplicit

Create a new instance of class argument_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.
information(optional) Contains current information about member name, file path and line number in the file where the exception is occurred. Typically current_stack_frame_.

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