Inja 3.4.0
A Template Engine for Modern C++
Loading...
Searching...
No Matches
exceptions.hpp
1#ifndef INCLUDE_INJA_EXCEPTIONS_HPP_
2#define INCLUDE_INJA_EXCEPTIONS_HPP_
3
4#include <stdexcept>
5#include <string>
6
7namespace inja {
8
10 size_t line;
11 size_t column;
12};
13
14struct InjaError : public std::runtime_error {
15 const std::string type;
16 const std::string message;
17
18 const SourceLocation location;
19
20 explicit InjaError(const std::string& type, const std::string& message)
21 : std::runtime_error("[inja.exception." + type + "] " + message), type(type), message(message), location({0, 0}) {}
22
23 explicit InjaError(const std::string& type, const std::string& message, SourceLocation location)
24 : std::runtime_error("[inja.exception." + type + "] (at " + std::to_string(location.line) + ":" + std::to_string(location.column) + ") " + message),
25 type(type), message(message), location(location) {}
26};
27
28struct ParserError : public InjaError {
29 explicit ParserError(const std::string& message, SourceLocation location): InjaError("parser_error", message, location) {}
30};
31
32struct RenderError : public InjaError {
33 explicit RenderError(const std::string& message, SourceLocation location): InjaError("render_error", message, location) {}
34};
35
36struct FileError : public InjaError {
37 explicit FileError(const std::string& message): InjaError("file_error", message) {}
38 explicit FileError(const std::string& message, SourceLocation location): InjaError("file_error", message, location) {}
39};
40
41struct DataError : public InjaError {
42 explicit DataError(const std::string& message, SourceLocation location): InjaError("data_error", message, location) {}
43};
44
45} // namespace inja
46
47#endif // INCLUDE_INJA_EXCEPTIONS_HPP_
Definition: exceptions.hpp:41
Definition: exceptions.hpp:36
Definition: exceptions.hpp:14
Definition: exceptions.hpp:28
Definition: exceptions.hpp:32
Definition: exceptions.hpp:9