1#ifndef SOURCEMETA_CORE_URITEMPLATE_ERROR_H_
2#define SOURCEMETA_CORE_URITEMPLATE_ERROR_H_
4#ifndef SOURCEMETA_CORE_URITEMPLATE_EXPORT
5#include <sourcemeta/core/uritemplate_export.h>
16namespace sourcemeta::core {
22#pragma warning(disable : 4251 4275)
28 :
public std::exception {
33 [[nodiscard]]
auto what() const noexcept -> const
char *
override {
34 return "The input is not a valid URI Template";
38 [[nodiscard]]
auto column() const noexcept -> std::uint64_t {
43 std::uint64_t column_;
49 :
public std::runtime_error {
53 : std::runtime_error{message} {}
59 :
public std::exception {
63 const std::string_view
right)
66 [[nodiscard]]
auto what() const noexcept -> const
char *
override {
67 return "Variable name mismatch when adding route";
71 [[nodiscard]]
auto left() const noexcept -> const std::
string & {
76 [[nodiscard]]
auto right() const noexcept -> const std::
string & {
88 :
public std::exception {
93 : message_{message}, segment_{
segment} {}
95 [[nodiscard]]
auto what() const noexcept -> const
char *
override {
96 return this->message_;
100 [[nodiscard]]
auto segment() const noexcept -> const std::
string & {
101 return this->segment_;
105 const char *message_;
106 std::string segment_;
112class SOURCEMETA_CORE_URITEMPLATE_EXPORT
119 [[nodiscard]]
auto what() const noexcept -> const
char *
override {
120 return "Invalid operation identifier";
124 [[nodiscard]]
auto operation_id() const noexcept -> const std::
string & {
125 return this->operation_id_;
129 std::string operation_id_;
135class SOURCEMETA_CORE_URITEMPLATE_EXPORT
143 [[nodiscard]]
auto what() const noexcept -> const
char *
override {
144 return "Duplicate operation identifier";
148 [[nodiscard]]
auto operation_id() const noexcept -> const std::
string & {
149 return this->operation_id_;
153 std::string operation_id_;
159 :
public std::exception {
163 : path_{std::move(
path)}, message_{message} {}
165 [[nodiscard]]
auto what() const noexcept -> const
char *
override {
166 return this->message_;
170 [[nodiscard]]
auto path() const noexcept -> const std::filesystem::
path & {
175 std::filesystem::path path_;
176 const char *message_;
182 :
public std::exception {
186 : path_{std::move(
path)} {}
188 [[nodiscard]]
auto what() const noexcept -> const
char *
override {
189 return "Failed to open router file for reading";
193 [[nodiscard]]
auto path() const noexcept -> const std::filesystem::
path & {
198 std::filesystem::path path_;
202#pragma warning(default : 4251 4275)
auto segment() const noexcept -> const std::string &
Get the offending segment.
Definition uritemplate_error.h:100
auto operation_id() const noexcept -> const std::string &
Get the conflicting operation identifier.
Definition uritemplate_error.h:148
URITemplateParseError(const std::uint64_t column)
Construct an error given the column number where parsing failed.
Definition uritemplate_error.h:31
auto right() const noexcept -> const std::string &
Get the conflicting variable name.
Definition uritemplate_error.h:76
URITemplateExpansionError(const std::string &message)
Construct an error with a descriptive message.
Definition uritemplate_error.h:52
auto operation_id() const noexcept -> const std::string &
Get the offending operation identifier.
Definition uritemplate_error.h:124
URITemplateRouterDuplicateOperationIdError(const std::string_view operation_id)
Construct an error given the conflicting operation identifier.
Definition uritemplate_error.h:139
URITemplateRouterVariableMismatchError(const std::string_view left, const std::string_view right)
Construct an error given the existing and conflicting variable names.
Definition uritemplate_error.h:62
URITemplateRouterReadError(std::filesystem::path path)
Construct an error given the target path.
Definition uritemplate_error.h:185
URITemplateRouterInvalidOperationIdError(const std::string_view operation_id)
Construct an error given the offending operation identifier.
Definition uritemplate_error.h:116
URITemplateRouterInvalidSegmentError(const char *message, const std::string_view segment)
Construct an error given a descriptive message and the offending segment.
Definition uritemplate_error.h:91
auto left() const noexcept -> const std::string &
Get the existing variable name.
Definition uritemplate_error.h:71
URITemplateRouterSaveError(std::filesystem::path path, const char *message)
Construct an error given the target path and a descriptive message.
Definition uritemplate_error.h:162
auto column() const noexcept -> std::uint64_t
Get the column number of the error.
Definition uritemplate_error.h:38
auto path() const noexcept -> const std::filesystem::path &
Get the path that could not be read.
Definition uritemplate_error.h:193
auto path() const noexcept -> const std::filesystem::path &
Get the path that could not be saved.
Definition uritemplate_error.h:170