1 /** 2 * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. 3 * SPDX-License-Identifier: Apache-2.0. 4 */ 5 #include <aws/core/client/AWSError.h> 6 #include <aws/core/utils/HashingUtils.h> 7 #include <aws/core/utils/event/EventStreamErrors.h> 8 9 using namespace Aws::Client; 10 // using namespace Aws::S3; 11 // using namespace Aws::Utils; 12 13 namespace Aws 14 { 15 namespace Utils 16 { 17 namespace Event 18 { 19 namespace EventStreamErrorsMapper 20 { 21 /* 22 static const int EVENT_STREAM_NO_ERROR_HASH = HashingUtils::HashString("EventStreamNoError"); 23 static const int EVENT_STREAM_BUFFER_LENGTH_MISMATCH_HASH = HashingUtils::HashString("EventStreamBufferLengthMismatch"); 24 static const int EVENT_STREAM_INSUFFICIENT_BUFFER_LEN_HASH = HashingUtils::HashString("EventStreamInsufficientBufferLen"); 25 static const int EVENT_STREAM_MESSAGE_FIELD_SIZE_EXCEEDED_HASH = HashingUtils::HashString("EventStreamMessageFieldSizeExceeded"); 26 static const int EVENT_STREAM_PRELUDE_CHECKSUM_FAILURE_HASH = HashingUtils::HashString("EventStreamPreludeChecksumFailure"); 27 static const int EVENT_STREAM_MESSAGE_CHECKSUM_FAILURE_HASH = HashingUtils::HashString("EventStreamMessageChecksumFailure"); 28 static const int EVENT_STREAM_MESSAGE_INVALID_HEADERS_LEN_HASH = HashingUtils::HashString("EventStreamMessageInvalidHeadersLen"); 29 static const int EVENT_STREAM_MESSAGE_UNKNOWN_HEADER_TYPE_HASH = HashingUtils::HashString("EventStreamMessageUnknownHeaderType"); 30 static const int EVENT_STREAM_MESSAGE_PARSER_ILLEGAL_STATE_HASH = HashingUtils::HashString("EventStreamMessageParserIllegalState"); 31 */ GetNameForError(EventStreamErrors error)32 const char* GetNameForError(EventStreamErrors error) 33 { 34 switch (error) 35 { 36 case EventStreamErrors::EVENT_STREAM_NO_ERROR: 37 return "EventStreamNoError"; 38 case EventStreamErrors::EVENT_STREAM_BUFFER_LENGTH_MISMATCH: 39 return "EventStreamBufferLengthMismatch"; 40 case EventStreamErrors::EVENT_STREAM_INSUFFICIENT_BUFFER_LEN: 41 return "EventStreamInsufficientBufferLen"; 42 case EventStreamErrors::EVENT_STREAM_MESSAGE_FIELD_SIZE_EXCEEDED: 43 return "EventStreamMessageFieldSizeExceeded"; 44 case EventStreamErrors::EVENT_STREAM_PRELUDE_CHECKSUM_FAILURE: 45 return "EventStreamPreludeChecksumFailure"; 46 case EventStreamErrors::EVENT_STREAM_MESSAGE_CHECKSUM_FAILURE: 47 return "EventStreamMessageChecksumFailure"; 48 case EventStreamErrors::EVENT_STREAM_MESSAGE_INVALID_HEADERS_LEN: 49 return "EventStreamMessageInvalidHeadersLen"; 50 case EventStreamErrors::EVENT_STREAM_MESSAGE_UNKNOWN_HEADER_TYPE: 51 return "EventStreamMessageUnknownHeaderType"; 52 case EventStreamErrors::EVENT_STREAM_MESSAGE_PARSER_ILLEGAL_STATE: 53 return "EventStreamMessageParserIllegalState"; 54 default: 55 return "EventStreamUnknownError"; 56 } 57 } 58 GetAwsErrorForEventStreamError(EventStreamErrors error)59 AWSError<CoreErrors> GetAwsErrorForEventStreamError(EventStreamErrors error) 60 { 61 return AWSError<CoreErrors>(CoreErrors::UNKNOWN, GetNameForError(error), "", false); 62 } 63 } // namespace EventStreamErrorsMapper 64 } // namespace Event 65 } // namespace Utils 66 } // namespace Aws 67