Sourcemeta Core 0.0.0
Loading...
Searching...
No Matches
punycode_error.h
1#ifndef SOURCEMETA_CORE_PUNYCODE_ERROR_H_
2#define SOURCEMETA_CORE_PUNYCODE_ERROR_H_
3
4#ifndef SOURCEMETA_CORE_PUNYCODE_EXPORT
5#include <sourcemeta/core/punycode_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(disable : 4251 4275)
19#endif
20
23class SOURCEMETA_CORE_PUNYCODE_EXPORT PunycodeError : public std::exception {
24public:
26 PunycodeError(const char *message) : message_{message} {}
27 PunycodeError(std::string message) = delete;
28 PunycodeError(std::string &&message) = delete;
29 PunycodeError(std::string_view message) = delete;
30
31 [[nodiscard]] auto what() const noexcept -> const char * override {
32 return this->message_;
33 }
34
35private:
36 const char *message_;
37};
38
39#if defined(_MSC_VER)
40#pragma warning(default : 4251 4275)
41#endif
42
43} // namespace sourcemeta::core
44
45#endif
PunycodeError(const char *message)
Construct an error with the given message.
Definition punycode_error.h:26
Definition punycode_error.h:23