NoTeX 1.0.0
A modern noteworthy LaTeX template
Loading...
Searching...
No Matches
errors.hpp
Go to the documentation of this file.
1
11
12#pragma once
13
14#include <stdexcept>
15#include <string>
16#include <utility>
17
18namespace notex {
19
35
43class NotexError : public std::runtime_error {
44public:
50 NotexError(std::string message, ExitCode exit_code)
51 : std::runtime_error(std::move(message)), exit_code_(exit_code) {}
52
54 ExitCode exit_code() const noexcept { return exit_code_; }
55
56private:
57 ExitCode exit_code_;
58};
59
61class UsageError : public NotexError {
62public:
63 explicit UsageError(std::string message)
64 : NotexError(std::move(message), ExitCode::USAGE_ERROR) {}
65};
66
68class EnvironmentError : public NotexError {
69public:
70 explicit EnvironmentError(std::string message)
71 : NotexError(std::move(message), ExitCode::ENVIRONMENT_ERROR) {}
72};
73
75class ProjectNotFoundError : public NotexError {
76public:
77 explicit ProjectNotFoundError(std::string message)
78 : NotexError(std::move(message), ExitCode::PROJECT_NOT_FOUND_ERROR) {}
79};
80
82class FilesystemError : public NotexError {
83public:
84 explicit FilesystemError(std::string message)
85 : NotexError(std::move(message), ExitCode::FILESYSTEM_ERROR) {}
86};
87
89class ConfigError : public NotexError {
90public:
91 explicit ConfigError(std::string message)
92 : NotexError(std::move(message), ExitCode::CONFIG_ERROR) {}
93};
94
98class DocumentError : public NotexError {
99public:
100 explicit DocumentError(std::string message)
101 : NotexError(std::move(message), ExitCode::DOCUMENT_ERROR) {}
102};
103
104} // namespace notex
ExitCode exit_code() const noexcept
Definition errors.hpp:54
NotexError(std::string message, ExitCode exit_code)
Constructs an error with its message and exit code.
Definition errors.hpp:50
ExitCode
Process exit codes returned by the notex executable.
Definition errors.hpp:21
@ PROJECT_NOT_FOUND_ERROR
No .notex/ directory could be found.
Definition errors.hpp:27
@ FAILURE
An unexpected, unclassified error.
Definition errors.hpp:23
@ USAGE_ERROR
The command line was invalid.
Definition errors.hpp:24
@ FILESYSTEM_ERROR
A filesystem operation failed.
Definition errors.hpp:28
@ SUCCESS
The command completed successfully.
Definition errors.hpp:22