1 /**
2  * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
3  * SPDX-License-Identifier: Apache-2.0.
4  */
5 
6 #include <aws/core/client/AWSError.h>
7 #include <aws/core/utils/HashingUtils.h>
8 #include <aws/sagemaker-a2i-runtime/AugmentedAIRuntimeErrors.h>
9 
10 using namespace Aws::Client;
11 using namespace Aws::Utils;
12 using namespace Aws::AugmentedAIRuntime;
13 
14 namespace Aws
15 {
16 namespace AugmentedAIRuntime
17 {
18 namespace AugmentedAIRuntimeErrorMapper
19 {
20 
21 static const int CONFLICT_HASH = HashingUtils::HashString("ConflictException");
22 static const int SERVICE_QUOTA_EXCEEDED_HASH = HashingUtils::HashString("ServiceQuotaExceededException");
23 static const int INTERNAL_SERVER_HASH = HashingUtils::HashString("InternalServerException");
24 
25 
GetErrorForName(const char * errorName)26 AWSError<CoreErrors> GetErrorForName(const char* errorName)
27 {
28   int hashCode = HashingUtils::HashString(errorName);
29 
30   if (hashCode == CONFLICT_HASH)
31   {
32     return AWSError<CoreErrors>(static_cast<CoreErrors>(AugmentedAIRuntimeErrors::CONFLICT), false);
33   }
34   else if (hashCode == SERVICE_QUOTA_EXCEEDED_HASH)
35   {
36     return AWSError<CoreErrors>(static_cast<CoreErrors>(AugmentedAIRuntimeErrors::SERVICE_QUOTA_EXCEEDED), false);
37   }
38   else if (hashCode == INTERNAL_SERVER_HASH)
39   {
40     return AWSError<CoreErrors>(static_cast<CoreErrors>(AugmentedAIRuntimeErrors::INTERNAL_SERVER), false);
41   }
42   return AWSError<CoreErrors>(CoreErrors::UNKNOWN, false);
43 }
44 
45 } // namespace AugmentedAIRuntimeErrorMapper
46 } // namespace AugmentedAIRuntime
47 } // namespace Aws
48