/** * 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::MTurk; using namespace Aws::MTurk::Model; namespace Aws { namespace MTurk { template<> AWS_MTURK_API ServiceFault MTurkError::GetModeledError() { assert(this->GetErrorType() == MTurkErrors::SERVICE_FAULT); return ServiceFault(this->GetJsonPayload().View()); } template<> AWS_MTURK_API RequestError MTurkError::GetModeledError() { assert(this->GetErrorType() == MTurkErrors::REQUEST); return RequestError(this->GetJsonPayload().View()); } namespace MTurkErrorMapper { static const int SERVICE_FAULT_HASH = HashingUtils::HashString("ServiceFault"); static const int REQUEST_HASH = HashingUtils::HashString("RequestError"); AWSError GetErrorForName(const char* errorName) { int hashCode = HashingUtils::HashString(errorName); if (hashCode == SERVICE_FAULT_HASH) { return AWSError(static_cast(MTurkErrors::SERVICE_FAULT), false); } else if (hashCode == REQUEST_HASH) { return AWSError(static_cast(MTurkErrors::REQUEST), false); } return AWSError(CoreErrors::UNKNOWN, false); } } // namespace MTurkErrorMapper } // namespace MTurk } // namespace Aws