9#include <source_location>
33class Error :
public std::exception
44 Error(
const std::string& file,
int line,
const std::string&
what)
45 : what_(file +
":" + std::to_string(line) +
": " +
what)
52 virtual const char*
what() const noexcept
override {
return what_.c_str(); }
56 const std::string what_;
83 const std::string& file,
85 const std::string& func,
88 const std::string& clarification
93 func +
": Trying to perform binary operation " +
" " + std::to_string(lengthA) +
", "
94 + std::to_string(lengthB) +
" " + clarification
106#define NeoN_ASSERT_EQUAL_LENGTH(_op1, _op2) \
107 auto s1 = static_cast<localIdx>(_op1.size()); \
108 auto s2 = static_cast<localIdx>(_op2.size()); \
111 throw ::NeoN::DimensionMismatch( \
112 __FILE__, __LINE__, __func__, s1, s2, "expected equal dimensions" \
129 const auto begin = range.first;
130 const auto end = range.second;
132 if (begin < 0 || begin > end ||
static_cast<sizeType>(end) > size)
134 throw std::out_of_range(
"The chosen range is not valid!");
152 if (!std::in_range<localIdx>(value))
154 throw std::length_error(
"Value cannot be represented by localIdx!");
156 return static_cast<localIdx>(value);
161 std::string_view message,
162 const std::source_location location = std::source_location::current()
169 std::ostringstream error;
170 error <<
"Invalid input: " << message <<
"\nFile: \n"
171 << location.file_name() <<
"\nLine: " << location.line();
DimensionMismatch(const std::string &file, int line, const std::string &func, localIdx lengthA, localIdx lengthB, const std::string &clarification)
Error(const std::string &file, int line, const std::string &what)
virtual const char * what() const noexcept override
Custom exception class for NeoN.
Integer types used throughout NeoN.
localIdx toLocalIdx(sizeType value)
void validateRange(std::pair< localIdx, localIdx > range, sizeType size)
void validateInput(bool condition, std::string_view message, const std::source_location location=std::source_location::current())