/** * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. * SPDX-License-Identifier: Apache-2.0. */ #include #include #include #include #include using namespace Aws::Client; using namespace Aws::Utils; using namespace Aws::AmplifyBackend; using namespace Aws::AmplifyBackend::Model; namespace Aws { namespace AmplifyBackend { template<> AWS_AMPLIFYBACKEND_API NotFoundException AmplifyBackendError::GetModeledError() { assert(this->GetErrorType() == AmplifyBackendErrors::NOT_FOUND); return NotFoundException(this->GetJsonPayload().View()); } template<> AWS_AMPLIFYBACKEND_API TooManyRequestsException AmplifyBackendError::GetModeledError() { assert(this->GetErrorType() == AmplifyBackendErrors::TOO_MANY_REQUESTS); return TooManyRequestsException(this->GetJsonPayload().View()); } namespace AmplifyBackendErrorMapper { static const int NOT_FOUND_HASH = HashingUtils::HashString("NotFoundException"); static const int GATEWAY_TIMEOUT_HASH = HashingUtils::HashString("GatewayTimeoutException"); static const int TOO_MANY_REQUESTS_HASH = HashingUtils::HashString("TooManyRequestsException"); static const int BAD_REQUEST_HASH = HashingUtils::HashString("BadRequestException"); AWSError GetErrorForName(const char* errorName) { int hashCode = HashingUtils::HashString(errorName); if (hashCode == NOT_FOUND_HASH) { return AWSError(static_cast(AmplifyBackendErrors::NOT_FOUND), false); } else if (hashCode == GATEWAY_TIMEOUT_HASH) { return AWSError(static_cast(AmplifyBackendErrors::GATEWAY_TIMEOUT), false); } else if (hashCode == TOO_MANY_REQUESTS_HASH) { return AWSError(static_cast(AmplifyBackendErrors::TOO_MANY_REQUESTS), true); } else if (hashCode == BAD_REQUEST_HASH) { return AWSError(static_cast(AmplifyBackendErrors::BAD_REQUEST), false); } return AWSError(CoreErrors::UNKNOWN, false); } } // namespace AmplifyBackendErrorMapper } // namespace AmplifyBackend } // namespace Aws