2020-12-10 20:28:58 +03:00
|
|
|
// Copyright (c) Microsoft Corporation. All rights reserved.
|
|
|
|
// Licensed under the Apache 2.0 License.
|
|
|
|
#pragma once
|
|
|
|
|
2022-02-11 12:35:38 +03:00
|
|
|
#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
|
2022-08-08 17:21:22 +03:00
|
|
|
{
|
|
|
|
std::string auth_policy;
|
|
|
|
std::string code;
|
|
|
|
std::string message;
|
|
|
|
|
2023-05-05 12:50:47 +03:00
|
|
|
bool operator==(const ODataAuthErrorDetails&) const = default;
|
2022-08-08 17:21:22 +03:00
|
|
|
};
|
|
|
|
|
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);
|
2022-08-08 17:21:22 +03:00
|
|
|
|
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
|
|
|
};
|
|
|
|
|
2022-08-08 17:21:22 +03:00
|
|
|
DECLARE_JSON_TYPE_WITH_OPTIONAL_FIELDS(ODataError);
|
2020-12-10 20:28:58 +03:00
|
|
|
DECLARE_JSON_REQUIRED_FIELDS(ODataError, code, message);
|
2022-08-08 17:21:22 +03:00
|
|
|
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)
|
2022-12-22 18:21:27 +03:00
|
|
|
ERROR(NotImplemented)
|
2020-12-10 20:28:58 +03:00
|
|
|
ERROR(InvalidAuthenticationInfo)
|
|
|
|
ERROR(InvalidHeaderValue)
|
|
|
|
ERROR(InvalidInput)
|
2020-12-11 16:12:49 +03:00
|
|
|
ERROR(InvalidQueryParameterValue)
|
2020-12-10 20:28:58 +03:00
|
|
|
ERROR(InvalidResourceName)
|
|
|
|
ERROR(MissingRequiredHeader)
|
|
|
|
ERROR(ResourceNotFound)
|
|
|
|
ERROR(RequestNotSigned)
|
|
|
|
ERROR(UnsupportedHttpVerb)
|
2020-12-11 20:51:20 +03:00
|
|
|
ERROR(UnsupportedContentType)
|
2022-06-23 21:43:49 +03:00
|
|
|
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:
|
2022-01-28 22:08:03 +03:00
|
|
|
ERROR(SessionCapExhausted)
|
2020-12-10 20:28:58 +03:00
|
|
|
ERROR(FrontendNotOpen)
|
|
|
|
ERROR(KeyNotFound)
|
2021-01-19 17:39:17 +03:00
|
|
|
ERROR(NodeAlreadyRecovering)
|
2020-12-10 20:28:58 +03:00
|
|
|
ERROR(ProposalNotOpen)
|
|
|
|
ERROR(ProposalNotFound)
|
2021-03-22 22:21:44 +03:00
|
|
|
ERROR(ProposalFailedToValidate)
|
2021-01-19 17:39:17 +03:00
|
|
|
ERROR(ServiceNotWaitingForRecoveryShares)
|
2020-12-10 20:28:58 +03:00
|
|
|
ERROR(StateDigestMismatch)
|
|
|
|
ERROR(TransactionNotFound)
|
|
|
|
ERROR(TransactionCommitAttemptsExceedLimit)
|
|
|
|
ERROR(TransactionReplicationFailed)
|
|
|
|
ERROR(UnknownCertificate)
|
|
|
|
ERROR(VoteNotFound)
|
|
|
|
ERROR(VoteAlreadyExists)
|
2021-05-25 14:56:03 +03:00
|
|
|
ERROR(NodeCannotHandleRequest)
|
2021-09-14 21:18:53 +03:00
|
|
|
ERROR(TransactionPendingOrUnknown)
|
|
|
|
ERROR(TransactionInvalid)
|
2021-11-04 18:07:09 +03:00
|
|
|
ERROR(PrimaryNotFound)
|
2024-06-24 21:47:45 +03:00
|
|
|
ERROR(BackupNotFound)
|
2021-12-10 12:20:30 +03:00
|
|
|
ERROR(RequestAlreadyForwarded)
|
2022-07-28 15:06:21 +03:00
|
|
|
ERROR(NodeNotRetiredCommitted)
|
2022-11-21 21:11:18 +03:00
|
|
|
ERROR(SessionConsistencyLost)
|
2022-12-22 12:49:52 +03:00
|
|
|
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)
|
2023-09-28 19:28:49 +03:00
|
|
|
ERROR(TooManyPendingTransactions)
|
2023-09-27 15:58:04 +03:00
|
|
|
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)
|
2022-05-04 18:02:46 +03:00
|
|
|
ERROR(StartupSeqnoIsOld)
|
2021-08-26 17:48:15 +03:00
|
|
|
ERROR(CSRPublicKeyInvalid)
|
2020-12-10 20:28:58 +03:00
|
|
|
|
|
|
|
#undef ERROR
|
|
|
|
}
|
|
|
|
}
|