xtd 0.2.0
Loading...
Searching...
No Matches
argument_out_of_range_exception.h
Go to the documentation of this file.
1
4#pragma once
6#include "literals.h"
7
9namespace xtd {
24 public:
26
40 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) {}
50 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) {}
55 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) {}
66 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) {}
79 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) {}
81
86
88
96 template <typename value_t>
97 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) throw argument_out_of_range_exception {string::format("value ('{0}') must not be equal to `{1}`. (Parameter '{2}')\nActual value was {0}.", value, other, param_name, stack_frame)};}
104 template <typename value_t>
105 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) throw argument_out_of_range_exception {string::format("value ('{0}') must be greater than or equal to `{1}`. (Parameter '{2}')\nActual value was {0}.", value, other, param_name, stack_frame)};}
112 template <typename value_t>
113 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) throw argument_out_of_range_exception {string::format("value ('{0}') must be greater than `{1}`. (Parameter '{2}')\nActual value was {0}.", value, other, param_name, stack_frame)};}
120 template <typename value_t>
121 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) throw argument_out_of_range_exception {string::format("value ('{0}') must be less than or equal to `{1}`. (Parameter '{2}')\nActual value was {0}.", value, other, param_name, stack_frame)};}
128 template <typename value_t>
129 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) throw argument_out_of_range_exception {string::format("value ('{0}') must be less than `{1}`. (Parameter '{2}')\nActual value was {0}.", value, other, param_name, stack_frame)};}
135 template <typename value_t>
136 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)) throw argument_out_of_range_exception {string::format("value ('{0}') must be a non-negative value. (Parameter '{1}')\nActual value was {0}.", value, param_name, stack_frame)};}
142 template <typename value_t>
143 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)) throw argument_out_of_range_exception {string::format("value ('{0}') must be a non-negative and non-zero value. (Parameter '{1}')\nActual value was {0}.", value, param_name, stack_frame)};}
150 template <typename value_t>
151 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) throw argument_out_of_range_exception {string::format("value ('{0}') must be equal to `{1}`. (Parameter '{2}')\nActual value was {0}.", value, other, param_name, stack_frame)};}
157 template <typename value_t>
158 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)) throw argument_out_of_range_exception {string::format("value ('{0}') must be a non-positive value. (Parameter '{1}')\nActual value was {0}.", value, param_name, stack_frame)};}
164 template <typename value_t>
165 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)) throw argument_out_of_range_exception {string::format("value ('{0}') must be a non-positive and non-zero value. (Parameter '{1}')\nActual value was {0}.", value, param_name, stack_frame)};}
171 template <typename value_t>
172 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)) throw argument_out_of_range_exception {string::format("value ('{0}') must be a non-zero value. (Parameter '{1}')\nActual value was {0}.", value, param_name, stack_frame)};}
174
175 private:
176 const char* default_message() const noexcept {return "Specified argument is out of range of valid values."_t;}
177 };
178}
Contains xtd::argument_exception exception.
The exception that is thrown when one of the arguments provided to a method is not valid.
Definition argument_exception.h:24
The exception that is thrown when one of the arguments provided to a method is out of range.
Definition argument_out_of_range_exception.h:23
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.h:72
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.h:172
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.h:50
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.h:45
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.h:66
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.h:165
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.h:121
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.h:136
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.h:143
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.h:60
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.h:129
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.h:105
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.h:35
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.h:31
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.h:55
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.h:79
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.h:113
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.h:158
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.h:40
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.h:97
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.h:151
Represents text as a sequence of character units.
Definition basic_string.h:79
static const basic_string empty_string
Represents the empty basic_string.
Definition basic_string.h:124
Provides information about a xtd::diagnostics::stack_frame, which represents a function call on the c...
Definition stack_frame.h:47
static stack_frame current(const xtd::source_location &value=xtd::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 basic_string format(const basic_string< char > &fmt, args_t &&... args)
Writes the text representation of the specified arguments list, to string using the specified format ...
@ other
The operating system is other.
Contains xtd literals.
The xtd namespace contains all fundamental classes to access Hardware, Os, System,...
Definition xtd_about_box.h:10