Program Listing for File Abort.hpp¶
↰ Return to documentation for file (include/jet/Abort.hpp
)
#pragma once
#include <exception>
#include <iostream>
#include <sstream>
#define JET_ABORT(message) Jet::Abort(message, __FILE__, __LINE__, __func__)
#define JET_ABORT_IF(expression, message) \
if ((expression)) { \
JET_ABORT(message); \
}
#define JET_ABORT_IF_NOT(expression, message) \
if (!(expression)) { \
JET_ABORT(message); \
}
#define JET_ASSERT(expression) \
JET_ABORT_IF_NOT(expression, "Assertion failed: " #expression)
namespace Jet {
class Exception : public std::exception {
public:
explicit Exception(const std::string &err_msg) noexcept : err_msg(err_msg)
{
}
virtual ~Exception() = default;
const char *what() const noexcept { return err_msg.c_str(); }
private:
std::string err_msg;
};
inline void Abort(const char *message, const char *file_name, int line,
const char *function_name)
{
std::stringstream err_msg;
err_msg << "[" << file_name << "][Line:" << line
<< "][Method:" << function_name << "]: Error in Jet: " << message;
throw Exception(err_msg.str());
}
}; // namespace Jet
api/program_listing_file_include_jet_Abort.hpp
Download Python script
Download Notebook
View on GitHub