1 #ifndef SIPLASPLAS_UTILITY_EXCEPTION_HPP 2 #define SIPLASPLAS_UTILITY_EXCEPTION_HPP 4 #include "error_logger.hpp" 5 #include <ctti/type_id.hpp> 37 template<
typename Ex,
typename Message>
38 void logException(
const Message& message, std::size_t framesToSkip = 0)
71 logException<Ex>(exception.what(), framesToSkip + 1);
84 template<
typename Ex,
typename Base = std::exception>
88 template<std::
size_t N>
92 logException<Ex>(message);
95 Exception(
const std::string& message) :
98 logException<Ex>(message);
136 template<
typename Exception,
typename... Args>
139 auto formattedMessage = fmt::format(message, std::forward<Args>(args)...);
145 logException<Exception>(formattedMessage, framesToSkip + 1);
151 template<
typename Exception,
typename... Args>
187 return exceptionSkippingFrames<Exception>(1, message, std::forward<Args>(args)...);
193 template<
typename Exception,
typename... Args>
194 void Throw(
const std::string& message, Args&&... args)
196 throw cpp::exceptionSkippingFrames<Exception>(1, message, std::forward<Args>(args)...);
201 #endif // SIPLASPLAS_UTILITY_EXCEPTION_HPP Exception exception(const std::string &message, Args &&...args)
Instances an exception with a custom error message.
Definition: exception.hpp:185
Definition: canary_allocator.hpp:7
void logException(const Ex &exception, std::size_t framesToSkip=0)
Logs an exception.
Definition: exception.hpp:69
Exception exceptionSkippingFrames(std::size_t framesToSkip, const std::string &message, Args &&...args)
Instances an exception with a custom error message.
Definition: exception.hpp:137
void logErrorSkippingFrames(std::size_t framesToSkip, const Message &message, Args &&...args)
Log an error with its backtrace. Also skip the latest framesToSkip stack frames from stack trace...
Definition: error_logger.hpp:84
Declares a siplasplas exception type.
Definition: exception.hpp:85