38 template<
typename Callback,
typename Ret_TYPE,
typename ...Args_TYPE>
52 :
public std::exception,
54 #define ORIGINAL_ERROR_MSG "An error thrown"
56 mutable std::string msg_;
62 return ORIGINAL_ERROR_MSG;
69 explicit error(std::string msg) : msg_(std::move(msg)) {}
78 std::string message() const noexcept {
80 ss <<
"Original::" << this->
className() <<
": ";
81 if (!this->msg_.empty()){
82 ss << this->msg_ <<
".";
92 const char*
what() const noexcept
override {
93 this->msg_ = this->message();
94 return this->msg_.c_str();
109 template<
typename ERR, const
bool TRIGGERING_CONDITION>
110 requires ExtendsOf<error, ERR>
118 static_assert(!TRIGGERING_CONDITION);
131 #define ORIGINAL_OUT_OF_BOUND_ERROR_MSG "Wrong value given"
134 :
error(std::move(msg)) {}
137 return "outOfBoundError";
141 return ORIGINAL_OUT_OF_BOUND_ERROR_MSG;
152 #define ORIGINAL_VALUE_ERROR_ERROR_MSG "Wrong value given"
155 :
error(std::move(msg)) {}
162 return ORIGINAL_VALUE_ERROR_ERROR_MSG;
173 #define ORIGINAL_NULL_POINTER_ERROR_MSG "Attempting to access null pointer"
176 :
error(std::move(msg)) {}
179 return "nullPointerError";
183 return ORIGINAL_NULL_POINTER_ERROR_MSG;
194 #define ORIGINAL_UNSUPPORTED_METHOD_ERROR_MSG "Unsupported Method for the call"
197 :
error(std::move(msg)) {}
200 return "unSupportedMethodError";
204 return ORIGINAL_UNSUPPORTED_METHOD_ERROR_MSG;
215 #define ORIGINAL_NO_ELEMENT_ERROR_MSG "No such element"
218 :
error(std::move(msg)) {}
221 return "noElementError";
225 return ORIGINAL_NO_ELEMENT_ERROR_MSG;
236 #define ORIGINAL_CALLBACK_SIGNATURE_ERROR_MSG "Callback signature mismatch"
239 :
error(std::move(msg)) {}
242 return "callbackSignatureError";
246 return ORIGINAL_CALLBACK_SIGNATURE_ERROR_MSG;
257 #define ORIGINAL_CALLBACK_RETURN_TYPE_ERROR_MSG "Return type of callback mismatch"
260 :
error(std::move(msg)) {}
263 return "callbackReturnTypeError";
267 return ORIGINAL_CALLBACK_RETURN_TYPE_ERROR_MSG;
287 #define ORIGINAL_ALLOCATE_ERROR_MSG "Can not allocate memory"
290 :
error(std::move(msg)) {}
293 return "allocateError";
297 return ORIGINAL_ALLOCATE_ERROR_MSG;
308 #define ORIGINAL_SYS_ERROR_MSG "A system error triggered"
310 explicit sysError(std::string msg =
"")
311 :
error(std::move(msg)) {}
318 return ORIGINAL_SYS_ERROR_MSG;
326template<
typename Callback,
typename Ret_TYPE,
typename... Args_TYPE>
328 if constexpr (
constexpr bool is_valid = std::is_invocable_v<Callback, Args_TYPE...>;
332 using result_type = std::invoke_result_t<Callback, Args_TYPE...>;
333 if constexpr (
constexpr bool is_valid_return_type = std::is_same_v<result_type, Ret_TYPE>;
334 !is_valid_return_type)
339template <const
bool TRIGGERING_CONDITION>
343 static void asserts(){
344 static_assert(!TRIGGERING_CONDITION, ORIGINAL_ERROR_MSG);
348template <const
bool TRIGGERING_CONDITION>
352 static void asserts(){
353 static_assert(!TRIGGERING_CONDITION, ORIGINAL_OUT_OF_BOUND_ERROR_MSG);
357template <const
bool TRIGGERING_CONDITION>
361 static void asserts(){
362 static_assert(!TRIGGERING_CONDITION, ORIGINAL_VALUE_ERROR_ERROR_MSG);
366template <const
bool TRIGGERING_CONDITION>
370 static void asserts(){
371 static_assert(!TRIGGERING_CONDITION, ORIGINAL_NULL_POINTER_ERROR_MSG);
375template <const
bool TRIGGERING_CONDITION>
379 static void asserts(){
380 static_assert(!TRIGGERING_CONDITION, ORIGINAL_UNSUPPORTED_METHOD_ERROR_MSG);
384template <const
bool TRIGGERING_CONDITION>
388 static void asserts(){
389 static_assert(!TRIGGERING_CONDITION, ORIGINAL_NO_ELEMENT_ERROR_MSG);
393template <const
bool TRIGGERING_CONDITION>
397 static void asserts(){
398 static_assert(!TRIGGERING_CONDITION, ORIGINAL_CALLBACK_SIGNATURE_ERROR_MSG);
402template <const
bool TRIGGERING_CONDITION>
406 static void asserts(){
407 static_assert(!TRIGGERING_CONDITION, ORIGINAL_CALLBACK_RETURN_TYPE_ERROR_MSG);
411template <const
bool TRIGGERING_CONDITION>
415 static void asserts(){
416 static_assert(!TRIGGERING_CONDITION, ORIGINAL_ALLOCATE_ERROR_MSG);
420template <const
bool TRIGGERING_CONDITION>
424 static void asserts(){
425 static_assert(!TRIGGERING_CONDITION, ORIGINAL_SYS_ERROR_MSG);
Exception for memory allocation failures.
Definition error.h:285
std::string className() const override
Gets the class name for type identification.
Definition error.h:292
std::string defaultMsg() const override
Provides default message when no custom message is supplied.
Definition error.h:296
Static utility for validating callback signatures.
Definition error.h:22
static void check()
Validates a callback's signature and return type.
Definition error.h:327
Exception for callback return type mismatch.
Definition error.h:255
std::string defaultMsg() const override
Provides default message when no custom message is supplied.
Definition error.h:266
std::string className() const override
Gets the class name for type identification.
Definition error.h:262
Exception for callback argument mismatch.
Definition error.h:234
std::string className() const override
Gets the class name for type identification.
Definition error.h:241
std::string defaultMsg() const override
Provides default message when no custom message is supplied.
Definition error.h:245
Base class for all exceptions in the Original project.
Definition error.h:53
error(std::string msg)
Constructs an exception with an optional message.
Definition error.h:69
const char * what() const noexcept override
Returns the full error message.
Definition error.h:92
std::string className() const override
Returns the class name as string.
Definition error.h:74
virtual std::string defaultMsg() const
Provides default message when no custom message is supplied.
Definition error.h:61
Exception for missing element requests.
Definition error.h:213
std::string className() const override
Returns the class name as string.
Definition error.h:220
std::string defaultMsg() const override
Provides default message when no custom message is supplied.
Definition error.h:224
Exception for null pointer dereference attempts.
Definition error.h:171
std::string defaultMsg() const override
Provides default message when no custom message is supplied.
Definition error.h:182
std::string className() const override
Returns the class name as string.
Definition error.h:178
Exception for container index out-of-range errors.
Definition error.h:129
std::string defaultMsg() const override
Provides default message when no custom message is supplied.
Definition error.h:140
std::string className() const override
Returns the class name as string.
Definition error.h:136
Base class providing polymorphic string conversion capabilities.
Definition printable.h:39
Compile-time error triggering utility.
Definition error.h:112
static void asserts()
Triggers static assertion if the condition is true.
Definition error.h:117
Exception for generic system failure.
Definition error.h:306
std::string className() const override
Returns the class name as string.
Definition error.h:313
std::string defaultMsg() const override
Provides default message when no custom message is supplied.
Definition error.h:317
Exception for unimplemented method calls.
Definition error.h:192
std::string defaultMsg() const override
Provides default message when no custom message is supplied.
Definition error.h:203
std::string className() const override
Returns the class name as string.
Definition error.h:199
Exception for invalid parameter values.
Definition error.h:150
std::string className() const override
Returns the class name as string.
Definition error.h:157
std::string defaultMsg() const override
Provides default message when no custom message is supplied.
Definition error.h:161
Main namespace for the project Original.
Definition algorithms.h:21
Interface for polymorphic string formatting and output.
Core type system foundations and concept definitions.