mirror of
https://github.com/pantor/inja.git
synced 2026-07-18 23:04:55 +00:00
add INJA_NOEXCEPTION
This commit is contained in:
@@ -5,6 +5,13 @@
|
||||
|
||||
#include <nlohmann/json.hpp>
|
||||
|
||||
#if (defined(__cpp_exceptions) || defined(__EXCEPTIONS) || defined(_CPPUNWIND)) && !defined(INJA_NOEXCEPTION)
|
||||
#define INJA_THROW(exception) throw exception
|
||||
#else
|
||||
#include <cstdlib>
|
||||
#define INJA_THROW(exception) std::abort()
|
||||
#endif
|
||||
|
||||
#include "environment.hpp"
|
||||
#include "exceptions.hpp"
|
||||
#include "parser.hpp"
|
||||
|
||||
@@ -51,7 +51,7 @@ class Parser {
|
||||
std::stack<ForStatementNode*> for_statement_stack;
|
||||
|
||||
void throw_parser_error(const std::string &message) {
|
||||
throw ParserError(message, lexer.current_position());
|
||||
INJA_THROW(ParserError(message, lexer.current_position()));
|
||||
}
|
||||
|
||||
void get_next_token() {
|
||||
|
||||
@@ -91,7 +91,7 @@ class Renderer : public NodeVisitor {
|
||||
|
||||
void throw_renderer_error(const std::string &message, const AstNode& node) {
|
||||
SourceLocation loc = get_source_location(current_template->content, node.pos);
|
||||
throw RenderError(message, loc);
|
||||
INJA_THROW(RenderError(message, loc));
|
||||
}
|
||||
|
||||
template<size_t N, bool throw_not_found=true>
|
||||
|
||||
@@ -18,7 +18,7 @@ inline void open_file_or_throw(const std::string &path, std::ifstream &file) {
|
||||
try {
|
||||
file.open(path);
|
||||
} catch (const std::ios_base::failure & /*e*/) {
|
||||
throw FileError("failed accessing file at '" + path + "'");
|
||||
INJA_THROW(FileError("failed accessing file at '" + path + "'"));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user