43 lines
1.2 KiB
C++
43 lines
1.2 KiB
C++
/**
|
|
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
* SPDX-License-Identifier: Apache-2.0.
|
|
*/
|
|
|
|
#include <aws/core/client/AWSError.h>
|
|
#include <aws/core/utils/HashingUtils.h>
|
|
#include <aws/codestar-connections/CodeStarconnectionsErrors.h>
|
|
|
|
using namespace Aws::Client;
|
|
using namespace Aws::Utils;
|
|
using namespace Aws::CodeStarconnections;
|
|
|
|
namespace Aws
|
|
{
|
|
namespace CodeStarconnections
|
|
{
|
|
namespace CodeStarconnectionsErrorMapper
|
|
{
|
|
|
|
static const int LIMIT_EXCEEDED_HASH = HashingUtils::HashString("LimitExceededException");
|
|
static const int RESOURCE_UNAVAILABLE_HASH = HashingUtils::HashString("ResourceUnavailableException");
|
|
|
|
|
|
AWSError<CoreErrors> GetErrorForName(const char* errorName)
|
|
{
|
|
int hashCode = HashingUtils::HashString(errorName);
|
|
|
|
if (hashCode == LIMIT_EXCEEDED_HASH)
|
|
{
|
|
return AWSError<CoreErrors>(static_cast<CoreErrors>(CodeStarconnectionsErrors::LIMIT_EXCEEDED), true);
|
|
}
|
|
else if (hashCode == RESOURCE_UNAVAILABLE_HASH)
|
|
{
|
|
return AWSError<CoreErrors>(static_cast<CoreErrors>(CodeStarconnectionsErrors::RESOURCE_UNAVAILABLE), false);
|
|
}
|
|
return AWSError<CoreErrors>(CoreErrors::UNKNOWN, false);
|
|
}
|
|
|
|
} // namespace CodeStarconnectionsErrorMapper
|
|
} // namespace CodeStarconnections
|
|
} // namespace Aws
|