1 /**
2  * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
3  * SPDX-License-Identifier: Apache-2.0.
4  */
5 #pragma once
6 
7 #include <aws/core/client/CoreErrors.h>
8 #include <aws/core/Core_EXPORTS.h>
9 
10 namespace Aws
11 {
12     namespace Utils
13     {
14         namespace Event
15         {
16             /**
17              * Errors encountered in event stream.
18              * These errors are associated with those in aws-c-event-stream library.
19              */
20             enum class EventStreamErrors
21             {
22                 EVENT_STREAM_NO_ERROR = 0,
23                 EVENT_STREAM_BUFFER_LENGTH_MISMATCH = 0x1000,
24                 EVENT_STREAM_INSUFFICIENT_BUFFER_LEN,
25                 EVENT_STREAM_MESSAGE_FIELD_SIZE_EXCEEDED,
26                 EVENT_STREAM_PRELUDE_CHECKSUM_FAILURE,
27                 EVENT_STREAM_MESSAGE_CHECKSUM_FAILURE,
28                 EVENT_STREAM_MESSAGE_INVALID_HEADERS_LEN,
29                 EVENT_STREAM_MESSAGE_UNKNOWN_HEADER_TYPE,
30                 EVENT_STREAM_MESSAGE_PARSER_ILLEGAL_STATE,
31                 EVENT_STREAM_UNKNOWN_ERROR
32             };
33 
34             namespace EventStreamErrorsMapper
35             {
36                 /**
37                  * Get name by its error type in event stream.
38                  */
39                 AWS_CORE_API const char* GetNameForError(Event::EventStreamErrors error);
40                 /**
41                  * Get AWSError by EventStreamError. The Error type will always be CoreErrors::UNKNOWN as an internal error in Event Stream, and it's always not retryable.
42                  */
43                 AWS_CORE_API Aws::Client::AWSError<Aws::Client::CoreErrors> GetAwsErrorForEventStreamError(Event::EventStreamErrors error);
44             } // namespace EventStreamErrorsMapper
45         } // namespace Event
46     } // namespace Utils
47 } // namespace Aws