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/devicefarm/DeviceFarmErrors.h>
9 #include <aws/devicefarm/model/TooManyTagsException.h>
10 #include <aws/devicefarm/model/TagOperationException.h>
11 #include <aws/devicefarm/model/TagPolicyException.h>
12
13 using namespace Aws::Client;
14 using namespace Aws::Utils;
15 using namespace Aws::DeviceFarm;
16 using namespace Aws::DeviceFarm::Model;
17
18 namespace Aws
19 {
20 namespace DeviceFarm
21 {
GetModeledError()22 template<> AWS_DEVICEFARM_API TooManyTagsException DeviceFarmError::GetModeledError()
23 {
24 assert(this->GetErrorType() == DeviceFarmErrors::TOO_MANY_TAGS);
25 return TooManyTagsException(this->GetJsonPayload().View());
26 }
27
GetModeledError()28 template<> AWS_DEVICEFARM_API TagOperationException DeviceFarmError::GetModeledError()
29 {
30 assert(this->GetErrorType() == DeviceFarmErrors::TAG_OPERATION);
31 return TagOperationException(this->GetJsonPayload().View());
32 }
33
GetModeledError()34 template<> AWS_DEVICEFARM_API TagPolicyException DeviceFarmError::GetModeledError()
35 {
36 assert(this->GetErrorType() == DeviceFarmErrors::TAG_POLICY);
37 return TagPolicyException(this->GetJsonPayload().View());
38 }
39
40 namespace DeviceFarmErrorMapper
41 {
42
43 static const int IDEMPOTENCY_HASH = HashingUtils::HashString("IdempotencyException");
44 static const int NOT_FOUND_HASH = HashingUtils::HashString("NotFoundException");
45 static const int ARGUMENT_HASH = HashingUtils::HashString("ArgumentException");
46 static const int LIMIT_EXCEEDED_HASH = HashingUtils::HashString("LimitExceededException");
47 static const int SERVICE_ACCOUNT_HASH = HashingUtils::HashString("ServiceAccountException");
48 static const int TOO_MANY_TAGS_HASH = HashingUtils::HashString("TooManyTagsException");
49 static const int TAG_OPERATION_HASH = HashingUtils::HashString("TagOperationException");
50 static const int INTERNAL_SERVICE_HASH = HashingUtils::HashString("InternalServiceException");
51 static const int TAG_POLICY_HASH = HashingUtils::HashString("TagPolicyException");
52 static const int CANNOT_DELETE_HASH = HashingUtils::HashString("CannotDeleteException");
53 static const int INVALID_OPERATION_HASH = HashingUtils::HashString("InvalidOperationException");
54 static const int NOT_ELIGIBLE_HASH = HashingUtils::HashString("NotEligibleException");
55
56
GetErrorForName(const char * errorName)57 AWSError<CoreErrors> GetErrorForName(const char* errorName)
58 {
59 int hashCode = HashingUtils::HashString(errorName);
60
61 if (hashCode == IDEMPOTENCY_HASH)
62 {
63 return AWSError<CoreErrors>(static_cast<CoreErrors>(DeviceFarmErrors::IDEMPOTENCY), false);
64 }
65 else if (hashCode == NOT_FOUND_HASH)
66 {
67 return AWSError<CoreErrors>(static_cast<CoreErrors>(DeviceFarmErrors::NOT_FOUND), false);
68 }
69 else if (hashCode == ARGUMENT_HASH)
70 {
71 return AWSError<CoreErrors>(static_cast<CoreErrors>(DeviceFarmErrors::ARGUMENT), false);
72 }
73 else if (hashCode == LIMIT_EXCEEDED_HASH)
74 {
75 return AWSError<CoreErrors>(static_cast<CoreErrors>(DeviceFarmErrors::LIMIT_EXCEEDED), true);
76 }
77 else if (hashCode == SERVICE_ACCOUNT_HASH)
78 {
79 return AWSError<CoreErrors>(static_cast<CoreErrors>(DeviceFarmErrors::SERVICE_ACCOUNT), false);
80 }
81 else if (hashCode == TOO_MANY_TAGS_HASH)
82 {
83 return AWSError<CoreErrors>(static_cast<CoreErrors>(DeviceFarmErrors::TOO_MANY_TAGS), false);
84 }
85 else if (hashCode == TAG_OPERATION_HASH)
86 {
87 return AWSError<CoreErrors>(static_cast<CoreErrors>(DeviceFarmErrors::TAG_OPERATION), false);
88 }
89 else if (hashCode == INTERNAL_SERVICE_HASH)
90 {
91 return AWSError<CoreErrors>(static_cast<CoreErrors>(DeviceFarmErrors::INTERNAL_SERVICE), false);
92 }
93 else if (hashCode == TAG_POLICY_HASH)
94 {
95 return AWSError<CoreErrors>(static_cast<CoreErrors>(DeviceFarmErrors::TAG_POLICY), false);
96 }
97 else if (hashCode == CANNOT_DELETE_HASH)
98 {
99 return AWSError<CoreErrors>(static_cast<CoreErrors>(DeviceFarmErrors::CANNOT_DELETE), false);
100 }
101 else if (hashCode == INVALID_OPERATION_HASH)
102 {
103 return AWSError<CoreErrors>(static_cast<CoreErrors>(DeviceFarmErrors::INVALID_OPERATION), false);
104 }
105 else if (hashCode == NOT_ELIGIBLE_HASH)
106 {
107 return AWSError<CoreErrors>(static_cast<CoreErrors>(DeviceFarmErrors::NOT_ELIGIBLE), false);
108 }
109 return AWSError<CoreErrors>(CoreErrors::UNKNOWN, false);
110 }
111
112 } // namespace DeviceFarmErrorMapper
113 } // namespace DeviceFarm
114 } // namespace Aws
115