CCF/include/ccf/odata_error.h

131 строка
3.4 KiB
C++
Исходник Постоянная ссылка Обычный вид История

2020-12-10 20:28:58 +03:00
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the Apache 2.0 License.
#pragma once
#include "ccf/ds/json.h"
2022-02-14 20:52:04 +03:00
#include "ccf/http_status.h"
2020-12-10 20:28:58 +03:00
namespace ccf
{
2023-05-05 12:50:47 +03:00
struct ODataAuthErrorDetails
{
std::string auth_policy;
std::string code;
std::string message;
2023-05-05 12:50:47 +03:00
bool operator==(const ODataAuthErrorDetails&) const = default;
};
2023-05-05 12:50:47 +03:00
DECLARE_JSON_TYPE(ODataAuthErrorDetails);
DECLARE_JSON_REQUIRED_FIELDS(
ODataAuthErrorDetails, auth_policy, code, message);
struct ODataJSExceptionDetails
{
std::string code;
std::string message;
std::optional<std::string> trace;
bool operator==(const ODataJSExceptionDetails&) const = default;
};
DECLARE_JSON_TYPE_WITH_OPTIONAL_FIELDS(ODataJSExceptionDetails);
DECLARE_JSON_REQUIRED_FIELDS(ODataJSExceptionDetails, code, message);
DECLARE_JSON_OPTIONAL_FIELDS(ODataJSExceptionDetails, trace);
2020-12-10 20:28:58 +03:00
struct ODataError
{
std::string code;
std::string message;
2023-05-05 12:50:47 +03:00
std::vector<nlohmann::json> details = {};
2020-12-10 20:28:58 +03:00
};
DECLARE_JSON_TYPE_WITH_OPTIONAL_FIELDS(ODataError);
2020-12-10 20:28:58 +03:00
DECLARE_JSON_REQUIRED_FIELDS(ODataError, code, message);
DECLARE_JSON_OPTIONAL_FIELDS(ODataError, details);
2020-12-10 20:28:58 +03:00
struct ODataErrorResponse
{
ODataError error;
};
DECLARE_JSON_TYPE(ODataErrorResponse);
DECLARE_JSON_REQUIRED_FIELDS(ODataErrorResponse, error);
struct ErrorDetails
{
http_status status;
std::string code;
std::string msg;
};
namespace errors
{
#define ERROR(code) constexpr const char* code = #code;
// For inspiration, see:
// https://docs.microsoft.com/en-us/rest/api/storageservices/common-rest-api-error-codes
// Generic errors
ERROR(AuthorizationFailed)
ERROR(InternalError)
ERROR(NotImplemented)
2020-12-10 20:28:58 +03:00
ERROR(InvalidAuthenticationInfo)
ERROR(InvalidHeaderValue)
ERROR(InvalidInput)
ERROR(InvalidQueryParameterValue)
2020-12-10 20:28:58 +03:00
ERROR(InvalidResourceName)
ERROR(MissingRequiredHeader)
ERROR(ResourceNotFound)
ERROR(RequestNotSigned)
ERROR(UnsupportedHttpVerb)
ERROR(UnsupportedContentType)
ERROR(RequestBodyTooLarge)
ERROR(RequestHeaderTooLarge)
2024-04-17 10:48:38 +03:00
ERROR(PreconditionFailed)
2020-12-10 20:28:58 +03:00
// CCF-specific errors
// client-facing:
ERROR(SessionCapExhausted)
2020-12-10 20:28:58 +03:00
ERROR(FrontendNotOpen)
ERROR(KeyNotFound)
ERROR(NodeAlreadyRecovering)
2020-12-10 20:28:58 +03:00
ERROR(ProposalNotOpen)
ERROR(ProposalNotFound)
2021-03-22 22:21:44 +03:00
ERROR(ProposalFailedToValidate)
ERROR(ServiceNotWaitingForRecoveryShares)
2020-12-10 20:28:58 +03:00
ERROR(StateDigestMismatch)
ERROR(TransactionNotFound)
ERROR(TransactionCommitAttemptsExceedLimit)
ERROR(TransactionReplicationFailed)
ERROR(UnknownCertificate)
ERROR(VoteNotFound)
ERROR(VoteAlreadyExists)
ERROR(NodeCannotHandleRequest)
2021-09-14 21:18:53 +03:00
ERROR(TransactionPendingOrUnknown)
ERROR(TransactionInvalid)
ERROR(PrimaryNotFound)
ERROR(BackupNotFound)
ERROR(RequestAlreadyForwarded)
2022-07-28 15:06:21 +03:00
ERROR(NodeNotRetiredCommitted)
ERROR(SessionConsistencyLost)
ERROR(ExecutorDispatchFailed)
2023-01-24 14:37:22 +03:00
ERROR(ProposalReplay)
ERROR(ProposalCreatedTooLongAgo)
ERROR(InvalidCreatedAt)
2023-05-05 12:50:47 +03:00
ERROR(JSException)
ERROR(TooManyPendingTransactions)
ERROR(MissingApiVersionParameter)
ERROR(UnsupportedApiVersionValue)
2020-12-10 20:28:58 +03:00
// node-to-node (/join and /create):
ERROR(ConsensusTypeMismatch)
ERROR(InvalidQuote)
ERROR(InvalidNodeState)
ERROR(NodeAlreadyExists)
ERROR(StartupSeqnoIsOld)
ERROR(CSRPublicKeyInvalid)
2020-12-10 20:28:58 +03:00
#undef ERROR
}
}