Inja 3.5.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 <cstddef>
5#include <stdexcept>
6#include <string>
7
8namespace inja {
9
11 size_t line;
12 size_t column;
13};
14
15struct InjaError : public std::runtime_error {
16 const std::string type;
17 const std::string message;
18
19 const SourceLocation location;
20
21 explicit InjaError(const std::string& type, const std::string& message)
22 : std::runtime_error("[inja.exception." + type + "] " + message), type(type), message(message), location({0, 0}) {}
23
24 explicit InjaError(const std::string& type, const std::string& message, SourceLocation location)
25 : std::runtime_error("[inja.exception." + type + "] (at " + std::to_string(location.line) + ":" + std::to_string(location.column) + ") " + message),
26 type(type), message(message), location(location) {}
27};
28
29struct ParserError : public InjaError {
30 explicit ParserError(const std::string& message, SourceLocation location): InjaError("parser_error", message, location) {}
31};
32
33struct RenderError : public InjaError {
34 explicit RenderError(const std::string& message, SourceLocation location): InjaError("render_error", message, location) {}
35};
36
37struct FileError : public InjaError {
38 explicit FileError(const std::string& message): InjaError("file_error", message) {}
39 explicit FileError(const std::string& message, SourceLocation location): InjaError("file_error", message, location) {}
40};
41
42struct DataError : public InjaError {
43 explicit DataError(const std::string& message, SourceLocation location): InjaError("data_error", message, location) {}
44};
45
46} // namespace inja
47
48#endif // INCLUDE_INJA_EXCEPTIONS_HPP_
Definition exceptions.hpp:42
Definition exceptions.hpp:37
Definition exceptions.hpp:15
Definition exceptions.hpp:29
Definition exceptions.hpp:33
Definition exceptions.hpp:10