@@ -62,6 +62,17 @@ AWSError<CoreErrors> JsonErrorMarshaller::Marshall(const Aws::Http::HttpResponse
6262
6363 if (httpResponse.HasHeader (ERROR_TYPE_HEADER)) {
6464 error = Marshall (httpResponse.GetHeader (ERROR_TYPE_HEADER), message);
65+ } else if (httpResponse.HasHeader (QUERY_ERROR_HEADER)) {
66+ auto errorCodeString = httpResponse.GetHeader (QUERY_ERROR_HEADER);
67+ auto locationOfSemicolon = errorCodeString.find_first_of (' ;' );
68+ Aws::String errorCode;
69+
70+ if (locationOfSemicolon != Aws::String::npos) {
71+ errorCode = errorCodeString.substr (0 , locationOfSemicolon);
72+ } else {
73+ errorCode = errorCodeString;
74+ }
75+ error = Marshall (errorCode, message);
6576 } else if (payloadView.ValueExists (TYPE)) {
6677 error = Marshall (payloadView.GetString (TYPE), message);
6778 } else {
@@ -256,45 +267,6 @@ AWSError<CoreErrors> AWSErrorMarshaller::FindErrorByHttpResponseCode(Aws::Http::
256267}
257268
258269void JsonErrorMarshallerQueryCompatible::MarshallError (AWSError<CoreErrors>& error, const Http::HttpResponse& httpResponse) const {
259- if (!error.GetExceptionName ().empty ()) {
260- auto exceptionPayload = GetJsonPayloadHttpResponse (httpResponse);
261- auto payloadView = JsonView (exceptionPayload);
262- /*
263- AWS Query-Compatible mode: This is a special setting that allows
264- certain AWS services to communicate using a specific "query"
265- format, which can send customized error codes. Users are divided
266- into different groups based on how they communicate with the
267- service: Group #1: Users using the AWS Query format, receiving
268- custom error codes. Group #2: Users using the regular AWS JSON
269- format without the trait, receiving standard error codes. Group #3:
270- Users using the AWS JSON format with the trait, receiving custom
271- error codes.
272-
273- The header "x-amzn-query-error" shouldn't be present if it's not
274- awsQueryCompatible, so added checks for it.
275- */
276-
277- if (httpResponse.HasHeader (QUERY_ERROR_HEADER)) {
278- auto errorCodeString = httpResponse.GetHeader (QUERY_ERROR_HEADER);
279- auto locationOfSemicolon = errorCodeString.find_first_of (' ;' );
280- Aws::String errorCode;
281-
282- if (locationOfSemicolon != Aws::String::npos) {
283- errorCode = errorCodeString.substr (0 , locationOfSemicolon);
284- } else {
285- errorCode = errorCodeString;
286- }
287-
288- error.SetExceptionName (errorCode);
289- }
290- // check for exception name from payload field 'type'
291- else if (payloadView.ValueExists (TYPE)) {
292- // handle missing header and parse code from message
293- const auto & typeStr = payloadView.GetString (TYPE);
294- auto locationOfPound = typeStr.find_first_of (' #' );
295- if (locationOfPound != Aws::String::npos) {
296- error.SetExceptionName (typeStr.substr (locationOfPound + 1 ));
297- }
298- }
299- }
270+ AWS_UNREFERENCED_PARAM (error);
271+ AWS_UNREFERENCED_PARAM (httpResponse);
300272}
0 commit comments