xtd 0.2.0
argument_out_of_range_exception.hpp
Go to the documentation of this file.
1
4#pragma once
6
8namespace xtd {
23 public:
25
39 explicit argument_out_of_range_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_out_of_range_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_out_of_range_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_out_of_range_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_out_of_range_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
85
87
95 template<class value_t>
96 static void throw_if_equal(const value_t& value, const value_t& other, const xtd::string& param_name = xtd::string::empty_string, const xtd::diagnostics::stack_frame& stack_frame = xtd::diagnostics::stack_frame::current()) {if (value == other) xtd::helpers::throw_helper::throws(xtd::helpers::exception_case::argument_out_of_range, string::format("value ('{0}') must not be equal to `{1}`. (Parameter '{2}')\nActual value was {0}.", value, other, param_name, stack_frame).c_str());}
103 template<class value_t>
104 static void throw_if_less_than(const value_t& value, const value_t& other, const xtd::string& param_name = xtd::string::empty_string, const xtd::diagnostics::stack_frame& stack_frame = xtd::diagnostics::stack_frame::current()) {if (value < other) xtd::helpers::throw_helper::throws(xtd::helpers::exception_case::argument_out_of_range, string::format("value ('{0}') must be greater than or equal to `{1}`. (Parameter '{2}')\nActual value was {0}.", value, other, param_name, stack_frame).c_str());}
111 template<class value_t>
112 static void throw_if_less_than_or_equal(const value_t& value, const value_t& other, const xtd::string& param_name = xtd::string::empty_string, const xtd::diagnostics::stack_frame& stack_frame = xtd::diagnostics::stack_frame::current()) {if (value <= other) xtd::helpers::throw_helper::throws(xtd::helpers::exception_case::argument_out_of_range, string::format("value ('{0}') must be greater than `{1}`. (Parameter '{2}')\nActual value was {0}.", value, other, param_name, stack_frame).cstr_());}
119 template<class value_t>
120 static void throw_if_greater_than(const value_t& value, const value_t& other, const xtd::string& param_name = xtd::string::empty_string, const xtd::diagnostics::stack_frame& stack_frame = xtd::diagnostics::stack_frame::current()) {if (value > other) xtd::helpers::throw_helper::throws(xtd::helpers::exception_case::argument_out_of_range, string::format("value ('{0}') must be less than or equal to `{1}`. (Parameter '{2}')\nActual value was {0}.", value, other, param_name, stack_frame).c_str());}
127 template<class value_t>
128 static void throw_if_greater_than_or_equal(const value_t& value, const value_t& other, const xtd::string& param_name = xtd::string::empty_string, const xtd::diagnostics::stack_frame& stack_frame = xtd::diagnostics::stack_frame::current()) {if (value >= other) xtd::helpers::throw_helper::throws(xtd::helpers::exception_case::argument_out_of_range, string::format("value ('{0}') must be less than `{1}`. (Parameter '{2}')\nActual value was {0}.", value, other, param_name, stack_frame).c_str());}
134 template<class value_t>
135 static void throw_if_negative(const value_t& value, const xtd::string& param_name = xtd::string::empty_string, const xtd::diagnostics::stack_frame& stack_frame = xtd::diagnostics::stack_frame::current()) {if (value < static_cast<value_t>(0)) xtd::helpers::throw_helper::throws(xtd::helpers::exception_case::argument_out_of_range, string::format("value ('{0}') must be a non-negative value. (Parameter '{1}')\nActual value was {0}.", value, param_name, stack_frame).c_str());}
141 template<class value_t>
142 static void throw_if_negative_or_zero(const value_t& value, const xtd::string& param_name = xtd::string::empty_string, const xtd::diagnostics::stack_frame& stack_frame = xtd::diagnostics::stack_frame::current()) {if (value <= static_cast<value_t>(0)) xtd::helpers::throw_helper::throws(xtd::helpers::exception_case::argument_out_of_range, string::format("value ('{0}') must be a non-negative and non-zero value. (Parameter '{1}')\nActual value was {0}.", value, param_name, stack_frame).c_str());}
149 template<class value_t>
150 static void throw_if_not_equal(const value_t& value, const value_t& other, const xtd::string& param_name = xtd::string::empty_string, const xtd::diagnostics::stack_frame& stack_frame = xtd::diagnostics::stack_frame::current()) {if (value != other) xtd::helpers::throw_helper::throws(xtd::helpers::exception_case::argument_out_of_range, string::format("value ('{0}') must be equal to `{1}`. (Parameter '{2}')\nActual value was {0}.", value, other, param_name, stack_frame).c_str());}
156 template<class value_t>
157 static void throw_if_positive(const value_t& value, const xtd::string& param_name = xtd::string::empty_string, const xtd::diagnostics::stack_frame& stack_frame = xtd::diagnostics::stack_frame::current()) {if (value > static_cast<value_t>(0)) xtd::helpers::throw_helper::throws(xtd::helpers::exception_case::argument_out_of_range, string::format("value ('{0}') must be a non-positive value. (Parameter '{1}')\nActual value was {0}.", value, param_name, stack_frame).c_str());}
163 template<class value_t>
164 static void throw_if_positive_or_zero(const value_t& value, const xtd::string& param_name = xtd::string::empty_string, const xtd::diagnostics::stack_frame& stack_frame = xtd::diagnostics::stack_frame::current()) {if (value >= static_cast<value_t>(0)) xtd::helpers::throw_helper::throws(xtd::helpers::exception_case::argument_out_of_range, string::format("value ('{0}') must be a non-positive and non-zero value. (Parameter '{1}')\nActual value was {0}.", value, param_name, stack_frame).c_str());}
170 template<class value_t>
171 static void throw_if_zero(const value_t& value, const xtd::string& param_name = xtd::string::empty_string, const xtd::diagnostics::stack_frame& stack_frame = xtd::diagnostics::stack_frame::current()) {if (value == static_cast<value_t>(0)) xtd::helpers::throw_helper::throws(xtd::helpers::exception_case::argument_out_of_range, string::format("value ('{0}') must be a non-zero value. (Parameter '{1}')\nActual value was {0}.", value, param_name, stack_frame).c_str());}
173
174 private:
175 const char* default_message() const noexcept {return "Specified argument is out of range of valid values."_t;}
176 };
177}
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 out of range.
Definition argument_out_of_range_exception.hpp:22
argument_out_of_range_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::argument_out_of_range_exception.
Definition argument_out_of_range_exception.hpp:71
static void throw_if_zero(const value_t &value, 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_out_of_range_exception if value is zero.
Definition argument_out_of_range_exception.hpp:171
argument_out_of_range_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::argument_out_of_range_exception.
Definition argument_out_of_range_exception.hpp:49
argument_out_of_range_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::argument_out_of_range_exception.
Definition argument_out_of_range_exception.hpp:44
argument_out_of_range_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::argument_out_of_range_exception.
Definition argument_out_of_range_exception.hpp:65
static void throw_if_positive_or_zero(const value_t &value, 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_out_of_range_exception if value is positive or zero.
Definition argument_out_of_range_exception.hpp:164
static void throw_if_greater_than(const value_t &value, const value_t &other, 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_out_of_range_exception if value is greater than other.
Definition argument_out_of_range_exception.hpp:120
static void throw_if_negative(const value_t &value, 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_out_of_range_exception if value is negative.
Definition argument_out_of_range_exception.hpp:135
static void throw_if_negative_or_zero(const value_t &value, 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_out_of_range_exception if value is negative or zero.
Definition argument_out_of_range_exception.hpp:142
argument_out_of_range_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::argument_out_of_range_exception.
Definition argument_out_of_range_exception.hpp:59
static void throw_if_greater_than_or_equal(const value_t &value, const value_t &other, 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_out_of_range_exception if value is greater than or equal to other.
Definition argument_out_of_range_exception.hpp:128
static void throw_if_less_than(const value_t &value, const value_t &other, 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_out_of_range_exception if value is less than other.
Definition argument_out_of_range_exception.hpp:104
argument_out_of_range_exception(const xtd::string &message, const xtd::diagnostics::stack_frame &stack_frame=xtd::diagnostics::stack_frame::current())
Create a new instance of class xtd::argument_out_of_range_exception.
Definition argument_out_of_range_exception.hpp:34
argument_out_of_range_exception(const xtd::diagnostics::stack_frame &stack_frame=xtd::diagnostics::stack_frame::current())
Create a new instance of class xtd::argument_out_of_range_exception.
Definition argument_out_of_range_exception.hpp:30
argument_out_of_range_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::argument_out_of_range_exception.
Definition argument_out_of_range_exception.hpp:54
argument_out_of_range_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::argument_out_of_range_exception.
Definition argument_out_of_range_exception.hpp:78
static void throw_if_less_than_or_equal(const value_t &value, const value_t &other, 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_out_of_range_exception if value is less than or equal to other.
Definition argument_out_of_range_exception.hpp:112
static void throw_if_positive(const value_t &value, 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_out_of_range_exception if value is positive.
Definition argument_out_of_range_exception.hpp:157
argument_out_of_range_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::argument_out_of_range_exception.
Definition argument_out_of_range_exception.hpp:39
static void throw_if_equal(const value_t &value, const value_t &other, 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_out_of_range_exception if value is equal to other.
Definition argument_out_of_range_exception.hpp:96
static void throw_if_not_equal(const value_t &value, const value_t &other, 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_out_of_range_exception if value is not equal to other.
Definition argument_out_of_range_exception.hpp:150
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_out_of_range
The argument is out of range.
Definition exception_case.hpp:35
xtd::basic_string< char > string
Represents text as a sequence of UTF-8 code units.
Definition __string_definitions.hpp:43
@ other
The operating system is other.
Definition platform_id.hpp:58
The xtd namespace contains all fundamental classes to access Hardware, Os, System,...
Definition abstract_object.hpp:8