48 lines
1.3 KiB
C++
48 lines
1.3 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/pi/PIErrors.h>
|
|||
|
|
|
|||
|
|
using namespace Aws::Client;
|
|||
|
|
using namespace Aws::Utils;
|
|||
|
|
using namespace Aws::PI;
|
|||
|
|
|
|||
|
|
namespace Aws
|
|||
|
|
{
|
|||
|
|
namespace PI
|
|||
|
|
{
|
|||
|
|
namespace PIErrorMapper
|
|||
|
|
{
|
|||
|
|
|
|||
|
|
static const int INTERNAL_SERVICE_HASH = HashingUtils::HashString("InternalServiceError");
|
|||
|
|
static const int NOT_AUTHORIZED_HASH = HashingUtils::HashString("NotAuthorizedException");
|
|||
|
|
static const int INVALID_ARGUMENT_HASH = HashingUtils::HashString("InvalidArgumentException");
|
|||
|
|
|
|||
|
|
|
|||
|
|
AWSError<CoreErrors> GetErrorForName(const char* errorName)
|
|||
|
|
{
|
|||
|
|
int hashCode = HashingUtils::HashString(errorName);
|
|||
|
|
|
|||
|
|
if (hashCode == INTERNAL_SERVICE_HASH)
|
|||
|
|
{
|
|||
|
|
return AWSError<CoreErrors>(static_cast<CoreErrors>(PIErrors::INTERNAL_SERVICE), false);
|
|||
|
|
}
|
|||
|
|
else if (hashCode == NOT_AUTHORIZED_HASH)
|
|||
|
|
{
|
|||
|
|
return AWSError<CoreErrors>(static_cast<CoreErrors>(PIErrors::NOT_AUTHORIZED), false);
|
|||
|
|
}
|
|||
|
|
else if (hashCode == INVALID_ARGUMENT_HASH)
|
|||
|
|
{
|
|||
|
|
return AWSError<CoreErrors>(static_cast<CoreErrors>(PIErrors::INVALID_ARGUMENT), false);
|
|||
|
|
}
|
|||
|
|
return AWSError<CoreErrors>(CoreErrors::UNKNOWN, false);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
} // namespace PIErrorMapper
|
|||
|
|
} // namespace PI
|
|||
|
|
} // namespace Aws
|