| 1 | /* |
|---|---|
| 2 | * Copyright 2010-2017 Amazon.com, Inc. or its affiliates. All Rights Reserved. |
| 3 | * |
| 4 | * Licensed under the Apache License, Version 2.0 (the "License"). |
| 5 | * You may not use this file except in compliance with the License. |
| 6 | * A copy of the License is located at |
| 7 | * |
| 8 | * http://aws.amazon.com/apache2.0 |
| 9 | * |
| 10 | * or in the "license" file accompanying this file. This file is distributed |
| 11 | * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either |
| 12 | * express or implied. See the License for the specific language governing |
| 13 | * permissions and limitations under the License. |
| 14 | */ |
| 15 | #include <aws/core/client/AWSError.h> |
| 16 | #include <aws/core/utils/HashingUtils.h> |
| 17 | #include <aws/core/utils/event/EventStreamErrors.h> |
| 18 | |
| 19 | using namespace Aws::Client; |
| 20 | // using namespace Aws::S3; |
| 21 | // using namespace Aws::Utils; |
| 22 | |
| 23 | namespace Aws |
| 24 | { |
| 25 | namespace Utils |
| 26 | { |
| 27 | namespace Event |
| 28 | { |
| 29 | namespace EventStreamErrorsMapper |
| 30 | { |
| 31 | /* |
| 32 | static const int EVENT_STREAM_NO_ERROR_HASH = HashingUtils::HashString("EventStreamNoError"); |
| 33 | static const int EVENT_STREAM_BUFFER_LENGTH_MISMATCH_HASH = HashingUtils::HashString("EventStreamBufferLengthMismatch"); |
| 34 | static const int EVENT_STREAM_INSUFFICIENT_BUFFER_LEN_HASH = HashingUtils::HashString("EventStreamInsufficientBufferLen"); |
| 35 | static const int EVENT_STREAM_MESSAGE_FIELD_SIZE_EXCEEDED_HASH = HashingUtils::HashString("EventStreamMessageFieldSizeExceeded"); |
| 36 | static const int EVENT_STREAM_PRELUDE_CHECKSUM_FAILURE_HASH = HashingUtils::HashString("EventStreamPreludeChecksumFailure"); |
| 37 | static const int EVENT_STREAM_MESSAGE_CHECKSUM_FAILURE_HASH = HashingUtils::HashString("EventStreamMessageChecksumFailure"); |
| 38 | static const int EVENT_STREAM_MESSAGE_INVALID_HEADERS_LEN_HASH = HashingUtils::HashString("EventStreamMessageInvalidHeadersLen"); |
| 39 | static const int EVENT_STREAM_MESSAGE_UNKNOWN_HEADER_TYPE_HASH = HashingUtils::HashString("EventStreamMessageUnknownHeaderType"); |
| 40 | static const int EVENT_STREAM_MESSAGE_PARSER_ILLEGAL_STATE_HASH = HashingUtils::HashString("EventStreamMessageParserIllegalState"); |
| 41 | */ |
| 42 | const char* GetNameForError(EventStreamErrors error) |
| 43 | { |
| 44 | switch (error) |
| 45 | { |
| 46 | case EventStreamErrors::EVENT_STREAM_NO_ERROR: |
| 47 | return "EventStreamNoError"; |
| 48 | case EventStreamErrors::EVENT_STREAM_BUFFER_LENGTH_MISMATCH: |
| 49 | return "EventStreamBufferLengthMismatch"; |
| 50 | case EventStreamErrors::EVENT_STREAM_INSUFFICIENT_BUFFER_LEN: |
| 51 | return "EventStreamInsufficientBufferLen"; |
| 52 | case EventStreamErrors::EVENT_STREAM_MESSAGE_FIELD_SIZE_EXCEEDED: |
| 53 | return "EventStreamMessageFieldSizeExceeded"; |
| 54 | case EventStreamErrors::EVENT_STREAM_PRELUDE_CHECKSUM_FAILURE: |
| 55 | return "EventStreamPreludeChecksumFailure"; |
| 56 | case EventStreamErrors::EVENT_STREAM_MESSAGE_CHECKSUM_FAILURE: |
| 57 | return "EventStreamMessageChecksumFailure"; |
| 58 | case EventStreamErrors::EVENT_STREAM_MESSAGE_INVALID_HEADERS_LEN: |
| 59 | return "EventStreamMessageInvalidHeadersLen"; |
| 60 | case EventStreamErrors::EVENT_STREAM_MESSAGE_UNKNOWN_HEADER_TYPE: |
| 61 | return "EventStreamMessageUnknownHeaderType"; |
| 62 | case EventStreamErrors::EVENT_STREAM_MESSAGE_PARSER_ILLEGAL_STATE: |
| 63 | return "EventStreamMessageParserIllegalState"; |
| 64 | default: |
| 65 | return "EventStreamUnknownError"; |
| 66 | } |
| 67 | } |
| 68 | |
| 69 | AWSError<CoreErrors> GetAwsErrorForEventStreamError(EventStreamErrors error) |
| 70 | { |
| 71 | return AWSError<CoreErrors>(CoreErrors::UNKNOWN, GetNameForError(error), "", false); |
| 72 | } |
| 73 | } // namespace EventStreamErrorsMapper |
| 74 | } // namespace Event |
| 75 | } // namespace Utils |
| 76 | } // namespace Aws |
| 77 |