Decentralised Art Server
High-performance C++ backend that exposes HTML interface and a secure REST API for managing Performative Transactions entities
 
Loading...
Searching...
No Matches
parse_error.hpp
Go to the documentation of this file.
1#pragma once
2
3#include <cstdint>
4#include <string>
5#include <expected>
6#include <format>
7
8namespace dcn::parse
9{
11 {
12 enum class Kind : std::uint8_t
13 {
14 UNKNOWN = 0U,
15
16 INVALID_VALUE = 1U,
17 OUT_OF_RANGE = 2U,
18 TYPE_MISMATCH = 3U
19 };
20
22 std::string message = "";
23 };
24
25 template<class T>
26 using Result = std::expected<T, ParseError>;
27}
28
29template <>
30struct std::formatter<dcn::parse::ParseError::Kind> : std::formatter<std::string> {
31 auto format(const dcn::parse::ParseError::Kind & err, format_context& ctx) const {
32 switch(err)
33 {
34 case dcn::parse::ParseError::Kind::INVALID_VALUE : return formatter<string>::format("Invalid value", ctx);
35 case dcn::parse::ParseError::Kind::OUT_OF_RANGE : return formatter<string>::format("Out of range", ctx);
36 case dcn::parse::ParseError::Kind::TYPE_MISMATCH : return formatter<string>::format("Type mismatch", ctx);
37
38 default: return formatter<string>::format("Unknown", ctx);
39 }
40 return formatter<string>::format("", ctx);
41 }
42};
Definition auth.cpp:4
std::expected< T, ParseError > Result
Definition parse_error.hpp:26
Definition decentralised_art.hpp:29
Definition parse_error.hpp:11
std::string message
Definition parse_error.hpp:22
Kind
Definition parse_error.hpp:13
Kind kind
Definition parse_error.hpp:21
auto format(const dcn::parse::ParseError::Kind &err, format_context &ctx) const
Definition parse_error.hpp:31