Sourcemeta Core 0.0.0
Loading...
Searching...
No Matches
options_error.h
1#ifndef SOURCEMETA_CORE_OPTIONS_ERROR_H_
2#define SOURCEMETA_CORE_OPTIONS_ERROR_H_
3
4#ifndef SOURCEMETA_CORE_OPTIONS_EXPORT
5#include <sourcemeta/core/options_export.h>
6#endif
7
8#include <sourcemeta/core/error.h>
9
10#include <string> // std::string
11#include <string_view> // std::string_view
12
13namespace sourcemeta::core {
14
15SOURCEMETA_CORE_ERROR_WARNINGS_PUSH
16
19class SOURCEMETA_CORE_OPTIONS_EXPORT OptionsError : public Error {
20public:
23};
24
27class SOURCEMETA_CORE_OPTIONS_EXPORT OptionsUnknownOptionError
28 : public OptionsError {
29public:
31 OptionsUnknownOptionError(const std::string_view option)
32 : OptionsError{"Unknown option"}, option_{option} {}
33
35 [[nodiscard]] auto option() const noexcept -> std::string_view {
36 return this->option_;
37 }
38
39private:
40 std::string option_;
41};
42
45class SOURCEMETA_CORE_OPTIONS_EXPORT OptionsUnexpectedValueFlagError
46 : public OptionsError {
47public:
50 : OptionsError{"This flag cannot take a value"}, option_{option} {}
51
53 [[nodiscard]] auto option() const noexcept -> std::string_view {
54 return this->option_;
55 }
56
57private:
58 std::string option_;
59};
60
63class SOURCEMETA_CORE_OPTIONS_EXPORT OptionsMissingOptionValueError
64 : public OptionsError {
65public:
67 OptionsMissingOptionValueError(const std::string_view option)
68 : OptionsError{"This option must take a value"}, option_{option} {}
69
71 [[nodiscard]] auto option() const noexcept -> std::string_view {
72 return this->option_;
73 }
74
75private:
76 std::string option_;
77};
78
79SOURCEMETA_CORE_ERROR_WARNINGS_POP
80
81} // namespace sourcemeta::core
82
83#endif
auto message() const noexcept -> StaticString
Definition error_base.h:78
Error(const StaticString message) noexcept
Construct the error given its message.
Definition error_base.h:84
auto option() const noexcept -> std::string_view
The offending option.
Definition options_error.h:53
OptionsUnknownOptionError(const std::string_view option)
Construct the error given the offending option.
Definition options_error.h:31
auto option() const noexcept -> std::string_view
The offending option.
Definition options_error.h:71
OptionsMissingOptionValueError(const std::string_view option)
Construct the error given the offending option.
Definition options_error.h:67
OptionsUnexpectedValueFlagError(const std::string_view option)
Construct the error given the offending option.
Definition options_error.h:49
auto option() const noexcept -> std::string_view
The offending option.
Definition options_error.h:35
OptionsError(const StaticString message) noexcept
Construct the error given a message.
Definition options_error.h:22
Definition text_static_string.h:20