71 lines
2.0 KiB
C++
71 lines
2.0 KiB
C++
/**
|
|
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
* SPDX-License-Identifier: Apache-2.0.
|
|
*/
|
|
|
|
#include <aws/iotsitewise/model/ErrorCode.h>
|
|
#include <aws/core/utils/HashingUtils.h>
|
|
#include <aws/core/Globals.h>
|
|
#include <aws/core/utils/EnumParseOverflowContainer.h>
|
|
|
|
using namespace Aws::Utils;
|
|
|
|
|
|
namespace Aws
|
|
{
|
|
namespace IoTSiteWise
|
|
{
|
|
namespace Model
|
|
{
|
|
namespace ErrorCodeMapper
|
|
{
|
|
|
|
static const int VALIDATION_ERROR_HASH = HashingUtils::HashString("VALIDATION_ERROR");
|
|
static const int INTERNAL_FAILURE_HASH = HashingUtils::HashString("INTERNAL_FAILURE");
|
|
|
|
|
|
ErrorCode GetErrorCodeForName(const Aws::String& name)
|
|
{
|
|
int hashCode = HashingUtils::HashString(name.c_str());
|
|
if (hashCode == VALIDATION_ERROR_HASH)
|
|
{
|
|
return ErrorCode::VALIDATION_ERROR;
|
|
}
|
|
else if (hashCode == INTERNAL_FAILURE_HASH)
|
|
{
|
|
return ErrorCode::INTERNAL_FAILURE;
|
|
}
|
|
EnumParseOverflowContainer* overflowContainer = Aws::GetEnumOverflowContainer();
|
|
if(overflowContainer)
|
|
{
|
|
overflowContainer->StoreOverflow(hashCode, name);
|
|
return static_cast<ErrorCode>(hashCode);
|
|
}
|
|
|
|
return ErrorCode::NOT_SET;
|
|
}
|
|
|
|
Aws::String GetNameForErrorCode(ErrorCode enumValue)
|
|
{
|
|
switch(enumValue)
|
|
{
|
|
case ErrorCode::VALIDATION_ERROR:
|
|
return "VALIDATION_ERROR";
|
|
case ErrorCode::INTERNAL_FAILURE:
|
|
return "INTERNAL_FAILURE";
|
|
default:
|
|
EnumParseOverflowContainer* overflowContainer = Aws::GetEnumOverflowContainer();
|
|
if(overflowContainer)
|
|
{
|
|
return overflowContainer->RetrieveOverflow(static_cast<int>(enumValue));
|
|
}
|
|
|
|
return {};
|
|
}
|
|
}
|
|
|
|
} // namespace ErrorCodeMapper
|
|
} // namespace Model
|
|
} // namespace IoTSiteWise
|
|
} // namespace Aws
|