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/logs/CloudWatchLogsErrors.h>
9 #include <aws/logs/model/InvalidSequenceTokenException.h>
10 #include <aws/logs/model/DataAlreadyAcceptedException.h>
11 #include <aws/logs/model/MalformedQueryException.h>
12
13 using namespace Aws::Client;
14 using namespace Aws::Utils;
15 using namespace Aws::CloudWatchLogs;
16 using namespace Aws::CloudWatchLogs::Model;
17
18 namespace Aws
19 {
20 namespace CloudWatchLogs
21 {
GetModeledError()22 template<> AWS_CLOUDWATCHLOGS_API InvalidSequenceTokenException CloudWatchLogsError::GetModeledError()
23 {
24 assert(this->GetErrorType() == CloudWatchLogsErrors::INVALID_SEQUENCE_TOKEN);
25 return InvalidSequenceTokenException(this->GetJsonPayload().View());
26 }
27
GetModeledError()28 template<> AWS_CLOUDWATCHLOGS_API DataAlreadyAcceptedException CloudWatchLogsError::GetModeledError()
29 {
30 assert(this->GetErrorType() == CloudWatchLogsErrors::DATA_ALREADY_ACCEPTED);
31 return DataAlreadyAcceptedException(this->GetJsonPayload().View());
32 }
33
GetModeledError()34 template<> AWS_CLOUDWATCHLOGS_API MalformedQueryException CloudWatchLogsError::GetModeledError()
35 {
36 assert(this->GetErrorType() == CloudWatchLogsErrors::MALFORMED_QUERY);
37 return MalformedQueryException(this->GetJsonPayload().View());
38 }
39
40 namespace CloudWatchLogsErrorMapper
41 {
42
43 static const int INVALID_PARAMETER_HASH = HashingUtils::HashString("InvalidParameterException");
44 static const int OPERATION_ABORTED_HASH = HashingUtils::HashString("OperationAbortedException");
45 static const int RESOURCE_ALREADY_EXISTS_HASH = HashingUtils::HashString("ResourceAlreadyExistsException");
46 static const int INVALID_SEQUENCE_TOKEN_HASH = HashingUtils::HashString("InvalidSequenceTokenException");
47 static const int DATA_ALREADY_ACCEPTED_HASH = HashingUtils::HashString("DataAlreadyAcceptedException");
48 static const int MALFORMED_QUERY_HASH = HashingUtils::HashString("MalformedQueryException");
49 static const int LIMIT_EXCEEDED_HASH = HashingUtils::HashString("LimitExceededException");
50 static const int INVALID_OPERATION_HASH = HashingUtils::HashString("InvalidOperationException");
51
52
GetErrorForName(const char * errorName)53 AWSError<CoreErrors> GetErrorForName(const char* errorName)
54 {
55 int hashCode = HashingUtils::HashString(errorName);
56
57 if (hashCode == INVALID_PARAMETER_HASH)
58 {
59 return AWSError<CoreErrors>(static_cast<CoreErrors>(CloudWatchLogsErrors::INVALID_PARAMETER), false);
60 }
61 else if (hashCode == OPERATION_ABORTED_HASH)
62 {
63 return AWSError<CoreErrors>(static_cast<CoreErrors>(CloudWatchLogsErrors::OPERATION_ABORTED), false);
64 }
65 else if (hashCode == RESOURCE_ALREADY_EXISTS_HASH)
66 {
67 return AWSError<CoreErrors>(static_cast<CoreErrors>(CloudWatchLogsErrors::RESOURCE_ALREADY_EXISTS), false);
68 }
69 else if (hashCode == INVALID_SEQUENCE_TOKEN_HASH)
70 {
71 return AWSError<CoreErrors>(static_cast<CoreErrors>(CloudWatchLogsErrors::INVALID_SEQUENCE_TOKEN), false);
72 }
73 else if (hashCode == DATA_ALREADY_ACCEPTED_HASH)
74 {
75 return AWSError<CoreErrors>(static_cast<CoreErrors>(CloudWatchLogsErrors::DATA_ALREADY_ACCEPTED), false);
76 }
77 else if (hashCode == MALFORMED_QUERY_HASH)
78 {
79 return AWSError<CoreErrors>(static_cast<CoreErrors>(CloudWatchLogsErrors::MALFORMED_QUERY), false);
80 }
81 else if (hashCode == LIMIT_EXCEEDED_HASH)
82 {
83 return AWSError<CoreErrors>(static_cast<CoreErrors>(CloudWatchLogsErrors::LIMIT_EXCEEDED), true);
84 }
85 else if (hashCode == INVALID_OPERATION_HASH)
86 {
87 return AWSError<CoreErrors>(static_cast<CoreErrors>(CloudWatchLogsErrors::INVALID_OPERATION), false);
88 }
89 return AWSError<CoreErrors>(CoreErrors::UNKNOWN, false);
90 }
91
92 } // namespace CloudWatchLogsErrorMapper
93 } // namespace CloudWatchLogs
94 } // namespace Aws
95