Sourcemeta Core 0.0.0
Loading...
Searching...
No Matches
markdown_error.h
1#ifndef SOURCEMETA_CORE_MARKDOWN_ERROR_H_
2#define SOURCEMETA_CORE_MARKDOWN_ERROR_H_
3
4#ifndef SOURCEMETA_CORE_MARKDOWN_EXPORT
5#include <sourcemeta/core/markdown_export.h>
6#endif
7
8#include <exception> // std::exception
9#include <string> // std::string
10#include <string_view> // std::string_view
11
12namespace sourcemeta::core {
13
14// Exporting symbols that depends on the standard C++ library is considered
15// safe.
16// https://learn.microsoft.com/en-us/cpp/error-messages/compiler-warnings/compiler-warning-level-2-c4275?view=msvc-170&redirectedfrom=MSDN
17#if defined(_MSC_VER)
18#pragma warning(push)
19#pragma warning(disable : 4251 4275)
20#endif
21
25class SOURCEMETA_CORE_MARKDOWN_EXPORT MarkdownError : public std::exception {
26public:
28 MarkdownError(const char *message) : message_{message} {}
29 MarkdownError(std::string message) = delete;
30 MarkdownError(std::string &&message) = delete;
31 MarkdownError(std::string_view message) = delete;
32
33 [[nodiscard]] auto what() const noexcept -> const char * override {
34 return this->message_;
35 }
36
37private:
38 const char *message_;
39};
40
41#if defined(_MSC_VER)
42#pragma warning(pop)
43#endif
44
45} // namespace sourcemeta::core
46
47#endif
MarkdownError(const char *message)
Construct an error with the given message.
Definition markdown_error.h:28
Definition markdown_error.h:25