/** * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. * SPDX-License-Identifier: Apache-2.0. */ #include #include #include #include #include #include using namespace Aws::Client; using namespace Aws::Utils; using namespace Aws::Athena; using namespace Aws::Athena::Model; namespace Aws { namespace Athena { template<> AWS_ATHENA_API ResourceNotFoundException AthenaError::GetModeledError() { assert(this->GetErrorType() == AthenaErrors::RESOURCE_NOT_FOUND); return ResourceNotFoundException(this->GetJsonPayload().View()); } template<> AWS_ATHENA_API TooManyRequestsException AthenaError::GetModeledError() { assert(this->GetErrorType() == AthenaErrors::TOO_MANY_REQUESTS); return TooManyRequestsException(this->GetJsonPayload().View()); } template<> AWS_ATHENA_API InvalidRequestException AthenaError::GetModeledError() { assert(this->GetErrorType() == AthenaErrors::INVALID_REQUEST); return InvalidRequestException(this->GetJsonPayload().View()); } namespace AthenaErrorMapper { static const int INTERNAL_SERVER_HASH = HashingUtils::HashString("InternalServerException"); static const int METADATA_HASH = HashingUtils::HashString("MetadataException"); static const int TOO_MANY_REQUESTS_HASH = HashingUtils::HashString("TooManyRequestsException"); static const int SESSION_ALREADY_EXISTS_HASH = HashingUtils::HashString("SessionAlreadyExistsException"); static const int INVALID_REQUEST_HASH = HashingUtils::HashString("InvalidRequestException"); AWSError GetErrorForName(const char* errorName) { int hashCode = HashingUtils::HashString(errorName); if (hashCode == INTERNAL_SERVER_HASH) { return AWSError(static_cast(AthenaErrors::INTERNAL_SERVER), false); } else if (hashCode == METADATA_HASH) { return AWSError(static_cast(AthenaErrors::METADATA), false); } else if (hashCode == TOO_MANY_REQUESTS_HASH) { return AWSError(static_cast(AthenaErrors::TOO_MANY_REQUESTS), true); } else if (hashCode == SESSION_ALREADY_EXISTS_HASH) { return AWSError(static_cast(AthenaErrors::SESSION_ALREADY_EXISTS), false); } else if (hashCode == INVALID_REQUEST_HASH) { return AWSError(static_cast(AthenaErrors::INVALID_REQUEST), false); } return AWSError(CoreErrors::UNKNOWN, false); } } // namespace AthenaErrorMapper } // namespace Athena } // namespace Aws