58 lines
1.8 KiB
C++
58 lines
1.8 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/fms/FMSErrors.h>
|
|
|
|
using namespace Aws::Client;
|
|
using namespace Aws::Utils;
|
|
using namespace Aws::FMS;
|
|
|
|
namespace Aws
|
|
{
|
|
namespace FMS
|
|
{
|
|
namespace FMSErrorMapper
|
|
{
|
|
|
|
static const int INTERNAL_ERROR_HASH = HashingUtils::HashString("InternalErrorException");
|
|
static const int LIMIT_EXCEEDED_HASH = HashingUtils::HashString("LimitExceededException");
|
|
static const int INVALID_TYPE_HASH = HashingUtils::HashString("InvalidTypeException");
|
|
static const int INVALID_INPUT_HASH = HashingUtils::HashString("InvalidInputException");
|
|
static const int INVALID_OPERATION_HASH = HashingUtils::HashString("InvalidOperationException");
|
|
|
|
|
|
AWSError<CoreErrors> GetErrorForName(const char* errorName)
|
|
{
|
|
int hashCode = HashingUtils::HashString(errorName);
|
|
|
|
if (hashCode == INTERNAL_ERROR_HASH)
|
|
{
|
|
return AWSError<CoreErrors>(static_cast<CoreErrors>(FMSErrors::INTERNAL_ERROR), false);
|
|
}
|
|
else if (hashCode == LIMIT_EXCEEDED_HASH)
|
|
{
|
|
return AWSError<CoreErrors>(static_cast<CoreErrors>(FMSErrors::LIMIT_EXCEEDED), true);
|
|
}
|
|
else if (hashCode == INVALID_TYPE_HASH)
|
|
{
|
|
return AWSError<CoreErrors>(static_cast<CoreErrors>(FMSErrors::INVALID_TYPE), false);
|
|
}
|
|
else if (hashCode == INVALID_INPUT_HASH)
|
|
{
|
|
return AWSError<CoreErrors>(static_cast<CoreErrors>(FMSErrors::INVALID_INPUT), false);
|
|
}
|
|
else if (hashCode == INVALID_OPERATION_HASH)
|
|
{
|
|
return AWSError<CoreErrors>(static_cast<CoreErrors>(FMSErrors::INVALID_OPERATION), false);
|
|
}
|
|
return AWSError<CoreErrors>(CoreErrors::UNKNOWN, false);
|
|
}
|
|
|
|
} // namespace FMSErrorMapper
|
|
} // namespace FMS
|
|
} // namespace Aws
|