xtd 0.2.0
argument_null_exception.hpp
Go to the documentation of this file.
1
4#pragma once
6
8namespace xtd {
23 public:
25
30 explicit argument_null_exception(const xtd::diagnostics::stack_frame& stack_frame = xtd::diagnostics::stack_frame::current()) : argument_exception(default_message(), stack_frame) {}
39 explicit argument_null_exception(const xtd::string& message, const std::error_code& error, const xtd::diagnostics::stack_frame& stack_frame = xtd::diagnostics::stack_frame::current()) : argument_exception(message, error, stack_frame) {}
49 explicit argument_null_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()) : argument_exception(message, error, help_link, stack_frame) {}
54 explicit argument_null_exception(const std::exception& inner_exception, const xtd::diagnostics::stack_frame& stack_frame = xtd::diagnostics::stack_frame::current()) : argument_exception(default_message(), inner_exception, stack_frame) {}
65 explicit argument_null_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()) : argument_exception(message, inner_exception, error, stack_frame) {}
78 explicit argument_null_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()) : argument_exception(message, inner_exception, error, help_link, stack_frame) {}
80
83 argument_null_exception& operator =(const argument_null_exception&) = default;
85
87
94 template<class object_t>
95 static void throw_if_null(const object_t* argument, const xtd::string& param_name = xtd::string::empty_string, const xtd::diagnostics::stack_frame& stack_frame = xtd::diagnostics::stack_frame::current()) {if (!argument) xtd::helpers::throw_helper::throws(xtd::helpers::exception_case::argument_null, string::format("The value cannot benull. (Parameter '{}')", param_name, stack_frame).c_str());}
101 template<class object_t>
102 static void throw_if_null(const std::optional<object_t>& argument, const xtd::string& param_name = xtd::string::empty_string, const xtd::diagnostics::stack_frame& stack_frame = xtd::diagnostics::stack_frame::current()) {if (!argument) xtd::helpers::throw_helper::throws(xtd::helpers::exception_case::argument_null, string::format("The value cannot be null. (Parameter '{}')", param_name, stack_frame).c_str());}
108 template<class object_t>
109 static void throw_if_null(const xtd::sptr<object_t>& argument, const xtd::string& param_name = xtd::string::empty_string, const xtd::diagnostics::stack_frame& stack_frame = xtd::diagnostics::stack_frame::current()) {if (!argument) xtd::helpers::throw_helper::throws(xtd::helpers::exception_case::argument_null, string::format("The value cannot be null. (Parameter '{}')", param_name, stack_frame).c_str());}
115 template<class object_t>
116 static void throw_if_null(const xtd::uptr<object_t>& argument, const xtd::string& param_name = xtd::string::empty_string, const xtd::diagnostics::stack_frame& stack_frame = xtd::diagnostics::stack_frame::current()) {if (!argument) xtd::helpers::throw_helper::throws(xtd::helpers::exception_case::argument_null, string::format("The value cannot be null. (Parameter '{}')", param_name, stack_frame).c_str());}
118 static void throw_if_null(std::nullptr_t argument, const xtd::string& param_name = xtd::string::empty_string, const xtd::diagnostics::stack_frame& stack_frame = xtd::diagnostics::stack_frame::current()) {xtd::helpers::throw_helper::throws(xtd::helpers::exception_case::argument_null, string::format("The value cannot be null. (Parameter '{}')", param_name, stack_frame).c_str());}
121
122 private:
123 const char* default_message() const noexcept {return "Value cannot be null."_t;}
124 };
125}
Contains xtd::argument_exception exception.
argument_exception(const xtd::diagnostics::stack_frame &stack_frame=xtd::diagnostics::stack_frame::current())
Create a new instance of class argument_exception.
Definition argument_exception.hpp:31
The exception that is thrown when one of the arguments provided to a method is null.
Definition argument_null_exception.hpp:22
static void throw_if_null(const object_t *argument, const xtd::string &param_name=xtd::string::empty_string, const xtd::diagnostics::stack_frame &stack_frame=xtd::diagnostics::stack_frame::current())
Throws an xtd::argument_null_exception if argument is null.
Definition argument_null_exception.hpp:95
argument_null_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 argument_null_exception.
Definition argument_null_exception.hpp:49
argument_null_exception(const xtd::diagnostics::stack_frame &stack_frame=xtd::diagnostics::stack_frame::current())
Create a new instance of class argument_null_exception.
Definition argument_null_exception.hpp:30
argument_null_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 argument_null_exception.
Definition argument_null_exception.hpp:71
argument_null_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 argument_null_exception.
Definition argument_null_exception.hpp:39
static void throw_if_null(const xtd::sptr< object_t > &argument, const xtd::string &param_name=xtd::string::empty_string, const xtd::diagnostics::stack_frame &stack_frame=xtd::diagnostics::stack_frame::current())
Throws an xtd::argument_null_exception if argument is null.
Definition argument_null_exception.hpp:109
static void throw_if_null(const std::optional< object_t > &argument, const xtd::string &param_name=xtd::string::empty_string, const xtd::diagnostics::stack_frame &stack_frame=xtd::diagnostics::stack_frame::current())
Throws an xtd::argument_null_exception if argument is null.
Definition argument_null_exception.hpp:102
argument_null_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 argument_null_exception.
Definition argument_null_exception.hpp:78
argument_null_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 argument_null_exception.
Definition argument_null_exception.hpp:44
argument_null_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 argument_null_exception.
Definition argument_null_exception.hpp:59
argument_null_exception(const std::exception &inner_exception, const xtd::diagnostics::stack_frame &stack_frame=xtd::diagnostics::stack_frame::current())
Create a new instance of class argument_null_exception.
Definition argument_null_exception.hpp:54
argument_null_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 argument_null_exception.
Definition argument_null_exception.hpp:65
argument_null_exception(const xtd::string &message, const xtd::diagnostics::stack_frame &stack_frame=xtd::diagnostics::stack_frame::current())
Create a new instance of class argument_null_exception.
Definition argument_null_exception.hpp:34
static void throw_if_null(const xtd::uptr< object_t > &argument, const xtd::string &param_name=xtd::string::empty_string, const xtd::diagnostics::stack_frame &stack_frame=xtd::diagnostics::stack_frame::current())
Throws an xtd::argument_null_exception if argument is null.
Definition argument_null_exception.hpp:116
Provides information about a xtd::diagnostics::stack_frame, which represents a function call on the c...
Definition stack_frame.hpp:48
static stack_frame current(const xtd::diagnostics::source_location &value=xtd::diagnostics::source_location::current()) noexcept
Crates a new xtd::diagnostics::stack_frame object corresponding to the location of the call site.
virtual const xtd::string & message() const noexcept
Gets message associate to the exception.
virtual exception_ref inner_exception() const noexcept
Gets the exception instance that caused the current exception.
virtual const xtd::string & help_link() const noexcept
Gets a link to the help file associated with this exception.
static void throws(xtd::helpers::exception_case exception_case, const source_location &location=source_location::current())
Throws an exption with specified exception case.
@ argument_null
The argument is null.
Definition exception_case.hpp:33
xtd::basic_string< char > string
Represents text as a sequence of UTF-8 code units.
Definition __string_definitions.hpp:43
xtd::shared_ptr_object< type_t > sptr
The xtd::sptr object is a shared pointer.
Definition sptr.hpp:25
xtd::unique_ptr_object< type_t > uptr
The xtd::uptr object is a unique pointer.
Definition uptr.hpp:25
The xtd namespace contains all fundamental classes to access Hardware, Os, System,...
Definition abstract_object.hpp:8