CCF
Loading...
Searching...
No Matches
odata_error.h
Go to the documentation of this file.
1// Copyright (c) Microsoft Corporation. All rights reserved.
2// Licensed under the Apache 2.0 License.
3#pragma once
4
5#include "ccf/ds/json.h"
6#include "ccf/http_status.h"
7
8namespace ccf
9{
11 {
12 std::string auth_policy;
13 std::string code;
14 std::string message;
15
16 bool operator==(const ODataAuthErrorDetails&) const = default;
17 };
18
21 ODataAuthErrorDetails, auth_policy, code, message);
22
24 {
25 std::string code;
26 std::string message;
27 std::optional<std::string> trace;
28
29 bool operator==(const ODataJSExceptionDetails&) const = default;
30 };
31
35
37 {
38 std::string code;
39 std::string message;
40 std::vector<nlohmann::json> details = {};
41
42 bool operator==(const ODataError&) const = default;
43 };
44
48
53
56
58 {
60 std::string code;
61 std::string msg;
62 };
63
64 namespace errors
65 {
66#define ERROR(code) constexpr const char* code = #code;
67
68 // For inspiration, see:
69 // https://docs.microsoft.com/en-us/rest/api/storageservices/common-rest-api-error-codes
70
71 // Generic errors
72 ERROR(AuthorizationFailed)
74 ERROR(NotImplemented)
75 ERROR(InvalidAuthenticationInfo)
76 ERROR(InvalidHeaderValue)
77 ERROR(InvalidInput)
78 ERROR(InvalidQueryParameterValue)
79 ERROR(InvalidResourceName)
80 ERROR(MissingRequiredHeader)
81 ERROR(ResourceNotFound)
82 ERROR(RequestNotSigned)
83 ERROR(UnsupportedHttpVerb)
84 ERROR(UnsupportedContentType)
85 ERROR(RequestBodyTooLarge)
86 ERROR(RequestHeaderTooLarge)
87 ERROR(PreconditionFailed)
88
89 // CCF-specific errors
90 // client-facing:
91 ERROR(SessionCapExhausted)
92 ERROR(FrontendNotOpen)
93 ERROR(KeyNotFound)
94 ERROR(NodeAlreadyRecovering)
95 ERROR(ProposalNotOpen)
96 ERROR(ProposalNotFound)
97 ERROR(ProposalFailedToValidate)
98 ERROR(ServiceNotWaitingForRecoveryShares)
99 ERROR(StateDigestMismatch)
100 ERROR(TransactionNotFound)
101 ERROR(TransactionCommitAttemptsExceedLimit)
102 ERROR(TransactionReplicationFailed)
103 ERROR(UnknownCertificate)
104 ERROR(VoteNotFound)
105 ERROR(VoteAlreadyExists)
106 ERROR(NodeCannotHandleRequest)
107 ERROR(TransactionPendingOrUnknown)
108 ERROR(TransactionInvalid)
109 ERROR(PrimaryNotFound)
110 ERROR(BackupNotFound)
111 ERROR(RequestAlreadyForwarded)
112 ERROR(NodeNotRetiredCommitted)
113 ERROR(SessionConsistencyLost)
114 ERROR(ExecutorDispatchFailed)
115 ERROR(ProposalReplay)
116 ERROR(ProposalCreatedTooLongAgo)
117 ERROR(InvalidCreatedAt)
118 ERROR(JSException)
119 ERROR(TooManyPendingTransactions)
120 ERROR(MissingApiVersionParameter)
121 ERROR(UnsupportedApiVersionValue)
122
123 // node-to-node (/join and /create):
124 ERROR(ConsensusTypeMismatch)
125 ERROR(InvalidQuote)
126 ERROR(InvalidNodeState)
127 ERROR(NodeAlreadyExists)
128 ERROR(StartupSeqnoIsOld)
129 ERROR(CSRPublicKeyInvalid)
130
131#undef ERROR
132 }
133}
#define DECLARE_JSON_REQUIRED_FIELDS(TYPE,...)
Definition json.h:714
#define DECLARE_JSON_TYPE(TYPE)
Definition json.h:663
#define DECLARE_JSON_TYPE_WITH_OPTIONAL_FIELDS(TYPE)
Definition json.h:690
#define DECLARE_JSON_OPTIONAL_FIELDS(TYPE,...)
Definition json.h:786
Definition app_interface.h:14
@ error
Definition tls_session.h:24
llhttp_status http_status
Definition http_status.h:9
#define ERROR(code)
Definition odata_error.h:66
Definition odata_error.h:58
std::string code
Definition odata_error.h:60
http_status status
Definition odata_error.h:59
std::string msg
Definition odata_error.h:61
Definition odata_error.h:11
std::string auth_policy
Definition odata_error.h:12
std::string code
Definition odata_error.h:13
std::string message
Definition odata_error.h:14
bool operator==(const ODataAuthErrorDetails &) const =default
Definition odata_error.h:50
ODataError error
Definition odata_error.h:51
Definition odata_error.h:37
std::string message
Definition odata_error.h:39
std::vector< nlohmann::json > details
Definition odata_error.h:40
std::string code
Definition odata_error.h:38
bool operator==(const ODataError &) const =default
Definition odata_error.h:24
bool operator==(const ODataJSExceptionDetails &) const =default
std::string message
Definition odata_error.h:26
std::optional< std::string > trace
Definition odata_error.h:27
std::string code
Definition odata_error.h:25