Sourcemeta Core 0.0.0
Loading...
Searching...
No Matches
semver_error.h
1#ifndef SOURCEMETA_CORE_SEMVER_ERROR_H_
2#define SOURCEMETA_CORE_SEMVER_ERROR_H_
3
4#ifndef SOURCEMETA_CORE_SEMVER_EXPORT
5#include <sourcemeta/core/semver_export.h>
6#endif
7
8#include <cstdint> // std::uint64_t
9#include <exception> // std::exception
10
11namespace sourcemeta::core {
12
13#if defined(_MSC_VER)
14#pragma warning(disable : 4251 4275)
15#endif
16
18class SOURCEMETA_CORE_SEMVER_EXPORT SemVerParseError : public std::exception {
19public:
21 SemVerParseError(const std::uint64_t column) : column_{column} {}
22
23 [[nodiscard]] auto what() const noexcept -> const char * override {
24 return "The input is not a valid Semantic Version";
25 }
26
28 [[nodiscard]] auto column() const noexcept -> std::uint64_t {
29 return this->column_;
30 }
31
32private:
33 std::uint64_t column_;
34};
35
37class SOURCEMETA_CORE_SEMVER_EXPORT SemVerOverflowError
38 : public std::exception {
39public:
41 SemVerOverflowError(const std::uint64_t column) : column_{column} {}
42
43 [[nodiscard]] auto what() const noexcept -> const char * override {
44 return "The numeric component of the Semantic Version overflows";
45 }
46
48 [[nodiscard]] auto column() const noexcept -> std::uint64_t {
49 return this->column_;
50 }
51
52private:
53 std::uint64_t column_;
54};
55
56#if defined(_MSC_VER)
57#pragma warning(default : 4251 4275)
58#endif
59
60} // namespace sourcemeta::core
61
62#endif
auto column() const noexcept -> std::uint64_t
The column at which the overflow occurred.
Definition semver_error.h:48
SemVerOverflowError(const std::uint64_t column)
Construct an error located at the given column of the input.
Definition semver_error.h:41
SemVerParseError(const std::uint64_t column)
Construct an error located at the given column of the input.
Definition semver_error.h:21
auto column() const noexcept -> std::uint64_t
The column at which the parsing failure occurred.
Definition semver_error.h:28