Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions generator/.DevConfigs/78714232-60db-41f4-8696-7764cc7bd5c9.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@


{
"services": [
{
"serviceName": "CloudWatch",
"type": "patch",
"changeLogMessages": [
"Improve AWS Query compatible error handling in unmarshallers."
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggestion: Fix error handling for services running in aws query compatible mode, where the generic exception was being thrown instead of specific modeled exceptions

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This isn't very accurate, as we have fixed this issue by #4225 otherwise we couldn't have released.

]
},
{
"serviceName": "SQS",
"type": "patch",
"changeLogMessages": [
"Improve AWS Query compatible error handling in unmarshallers."
]
}
]
}

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -9,26 +9,25 @@
protected void GenerateAWSQueryCompatibleBlock()
{
#>
var errorCode = errorResponse.Code;
var errorType = errorResponse.Type;
var queryHeaderKey = Amazon.Util.HeaderKeys.XAmzQueryError;
if (context.ResponseData.IsHeaderPresent(queryHeaderKey))
{
var queryError = context.ResponseData.GetHeaderValue(queryHeaderKey);
if (!string.IsNullOrEmpty(queryError) && queryError.Contains(";"))
var errorTypeName = errorResponse.Code;
var queryHeaderKey = Amazon.Util.HeaderKeys.XAmzQueryError;
if (context.ResponseData.IsHeaderPresent(queryHeaderKey))
{
var queryErrorParts = queryError.Split(';');
if (queryErrorParts.Length == 2)
var queryError = context.ResponseData.GetHeaderValue(queryHeaderKey);
if (!string.IsNullOrEmpty(queryError) && queryError.Contains(";"))
{
errorCode = queryErrorParts[0];
var errorTypeString = queryErrorParts[1];
if (Enum.IsDefined(typeof(ErrorType), errorTypeString))
var queryErrorParts = queryError.Split(';');
if (queryErrorParts.Length == 2)
{
errorType = (ErrorType) Enum.Parse(typeof(ErrorType), errorTypeString);
errorResponse.Code = queryErrorParts[0];
var errorTypeString = queryErrorParts[1];
if (Enum.IsDefined(typeof(ErrorType), errorTypeString))
{
errorResponse.Type = (ErrorType) Enum.Parse(typeof(ErrorType), errorTypeString);
}
}
}
}
}
<#+
}
#>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ namespace ServiceClientGenerator.Generators.Marshallers
/// Class to produce the template output
/// </summary>

#line 1 "C:\codebase\v3\AWSDotNetPublic\generator\ServiceClientGeneratorLib\Generators\Marshallers\JsonRPCExceptionUnmarshaller.tt"
#line 1 "C:\repos\aws-sdk-net-staging\generator\ServiceClientGeneratorLib\Generators\Marshallers\JsonRPCExceptionUnmarshaller.tt"
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.TextTemplating", "17.0.0.0")]
public partial class JsonRPCExceptionUnmarshaller : BaseResponseUnmarshaller
{
Expand All @@ -29,7 +29,7 @@ public partial class JsonRPCExceptionUnmarshaller : BaseResponseUnmarshaller
public override string TransformText()
{

#line 6 "C:\codebase\v3\AWSDotNetPublic\generator\ServiceClientGeneratorLib\Generators\Marshallers\JsonRPCExceptionUnmarshaller.tt"
#line 6 "C:\repos\aws-sdk-net-staging\generator\ServiceClientGeneratorLib\Generators\Marshallers\JsonRPCExceptionUnmarshaller.tt"

AddLicenseHeader();

Expand All @@ -41,29 +41,29 @@ public override string TransformText()
this.Write("using ThirdParty.Json.LitJson;\r\n\r\n#pragma warning disable CS0612,CS0618\r\nnamespac" +
"e ");

#line 14 "C:\codebase\v3\AWSDotNetPublic\generator\ServiceClientGeneratorLib\Generators\Marshallers\JsonRPCExceptionUnmarshaller.tt"
#line 14 "C:\repos\aws-sdk-net-staging\generator\ServiceClientGeneratorLib\Generators\Marshallers\JsonRPCExceptionUnmarshaller.tt"
this.Write(this.ToStringHelper.ToStringWithCulture(this.Config.Namespace));

#line default
#line hidden
this.Write(".Model.Internal.MarshallTransformations\r\n{\r\n /// <summary>\r\n /// Response U" +
"nmarshaller for ");

#line 17 "C:\codebase\v3\AWSDotNetPublic\generator\ServiceClientGeneratorLib\Generators\Marshallers\JsonRPCExceptionUnmarshaller.tt"
#line 17 "C:\repos\aws-sdk-net-staging\generator\ServiceClientGeneratorLib\Generators\Marshallers\JsonRPCExceptionUnmarshaller.tt"
this.Write(this.ToStringHelper.ToStringWithCulture(this.UnmarshallerBaseName));

#line default
#line hidden
this.Write(" Object\r\n /// </summary> \r\n public class ");

#line 19 "C:\codebase\v3\AWSDotNetPublic\generator\ServiceClientGeneratorLib\Generators\Marshallers\JsonRPCExceptionUnmarshaller.tt"
#line 19 "C:\repos\aws-sdk-net-staging\generator\ServiceClientGeneratorLib\Generators\Marshallers\JsonRPCExceptionUnmarshaller.tt"
this.Write(this.ToStringHelper.ToStringWithCulture(this.UnmarshallerBaseName));

#line default
#line hidden
this.Write("Unmarshaller : IErrorResponseUnmarshaller<");

#line 19 "C:\codebase\v3\AWSDotNetPublic\generator\ServiceClientGeneratorLib\Generators\Marshallers\JsonRPCExceptionUnmarshaller.tt"
#line 19 "C:\repos\aws-sdk-net-staging\generator\ServiceClientGeneratorLib\Generators\Marshallers\JsonRPCExceptionUnmarshaller.tt"
this.Write(this.ToStringHelper.ToStringWithCulture(this.UnmarshallerBaseName));

#line default
Expand All @@ -73,7 +73,7 @@ public override string TransformText()
"\r\n /// <param name=\"context\"></param>\r\n /// <returns></returns>\r\n " +
" public ");

#line 26 "C:\codebase\v3\AWSDotNetPublic\generator\ServiceClientGeneratorLib\Generators\Marshallers\JsonRPCExceptionUnmarshaller.tt"
#line 26 "C:\repos\aws-sdk-net-staging\generator\ServiceClientGeneratorLib\Generators\Marshallers\JsonRPCExceptionUnmarshaller.tt"
this.Write(this.ToStringHelper.ToStringWithCulture(this.UnmarshallerBaseName));

#line default
Expand All @@ -91,78 +91,35 @@ public override string TransformText()
/// <returns></returns>
public ");

#line 37 "C:\codebase\v3\AWSDotNetPublic\generator\ServiceClientGeneratorLib\Generators\Marshallers\JsonRPCExceptionUnmarshaller.tt"
#line 37 "C:\repos\aws-sdk-net-staging\generator\ServiceClientGeneratorLib\Generators\Marshallers\JsonRPCExceptionUnmarshaller.tt"
this.Write(this.ToStringHelper.ToStringWithCulture(this.UnmarshallerBaseName));

#line default
#line hidden
this.Write(" Unmarshall(JsonUnmarshallerContext context, Amazon.Runtime.Internal.ErrorRespons" +
"e errorResponse)\r\n {\r\n context.Read();\r\n\r\n");
"e errorResponse)\r\n {\r\n context.Read();\r\n\r\n ");

#line 41 "C:\codebase\v3\AWSDotNetPublic\generator\ServiceClientGeneratorLib\Generators\Marshallers\JsonRPCExceptionUnmarshaller.tt"

if (this.Config.ServiceModel.IsAwsQueryCompatible)
{
GenerateAWSQueryCompatibleBlock();


#line default
#line hidden
this.Write(" ");

#line 46 "C:\codebase\v3\AWSDotNetPublic\generator\ServiceClientGeneratorLib\Generators\Marshallers\JsonRPCExceptionUnmarshaller.tt"
#line 41 "C:\repos\aws-sdk-net-staging\generator\ServiceClientGeneratorLib\Generators\Marshallers\JsonRPCExceptionUnmarshaller.tt"
this.Write(this.ToStringHelper.ToStringWithCulture(this.UnmarshallerBaseName));

#line default
#line hidden
this.Write(" unmarshalledObject = new ");

#line 46 "C:\codebase\v3\AWSDotNetPublic\generator\ServiceClientGeneratorLib\Generators\Marshallers\JsonRPCExceptionUnmarshaller.tt"
#line 41 "C:\repos\aws-sdk-net-staging\generator\ServiceClientGeneratorLib\Generators\Marshallers\JsonRPCExceptionUnmarshaller.tt"
this.Write(this.ToStringHelper.ToStringWithCulture(this.UnmarshallerBaseName));

#line default
#line hidden
this.Write("(errorResponse.Message, errorResponse.InnerException,\r\n errorType," +
" errorCode, errorResponse.RequestId, errorResponse.StatusCode);\r\n");

#line 48 "C:\codebase\v3\AWSDotNetPublic\generator\ServiceClientGeneratorLib\Generators\Marshallers\JsonRPCExceptionUnmarshaller.tt"

}
else
this.Write(@"(errorResponse.Message, errorResponse.InnerException,
errorResponse.Type, errorResponse.Code, errorResponse.RequestId, errorResponse.StatusCode);
int targetDepth = context.CurrentDepth;
while (context.ReadAtDepth(targetDepth))
{


#line default
#line hidden
this.Write(" ");

#line 53 "C:\codebase\v3\AWSDotNetPublic\generator\ServiceClientGeneratorLib\Generators\Marshallers\JsonRPCExceptionUnmarshaller.tt"
this.Write(this.ToStringHelper.ToStringWithCulture(this.UnmarshallerBaseName));

#line default
#line hidden
this.Write(" unmarshalledObject = new ");

#line 53 "C:\codebase\v3\AWSDotNetPublic\generator\ServiceClientGeneratorLib\Generators\Marshallers\JsonRPCExceptionUnmarshaller.tt"
this.Write(this.ToStringHelper.ToStringWithCulture(this.UnmarshallerBaseName));

#line default
#line hidden
this.Write("(errorResponse.Message, errorResponse.InnerException,\r\n errorRespo" +
"nse.Type, errorResponse.Code, errorResponse.RequestId, errorResponse.StatusCode)" +
";\r\n");

#line 55 "C:\codebase\v3\AWSDotNetPublic\generator\ServiceClientGeneratorLib\Generators\Marshallers\JsonRPCExceptionUnmarshaller.tt"

}


#line default
#line hidden
this.Write(" \r\n int targetDepth = context.CurrentDepth;\r\n while " +
"(context.ReadAtDepth(targetDepth))\r\n {\r\n");
");

#line 62 "C:\codebase\v3\AWSDotNetPublic\generator\ServiceClientGeneratorLib\Generators\Marshallers\JsonRPCExceptionUnmarshaller.tt"
#line 47 "C:\repos\aws-sdk-net-staging\generator\ServiceClientGeneratorLib\Generators\Marshallers\JsonRPCExceptionUnmarshaller.tt"

if(this.Structure != null)
{
Expand All @@ -174,29 +131,29 @@ public override string TransformText()
#line hidden
this.Write(" if (context.TestExpression(\"");

#line 68 "C:\codebase\v3\AWSDotNetPublic\generator\ServiceClientGeneratorLib\Generators\Marshallers\JsonRPCExceptionUnmarshaller.tt"
#line 53 "C:\repos\aws-sdk-net-staging\generator\ServiceClientGeneratorLib\Generators\Marshallers\JsonRPCExceptionUnmarshaller.tt"
this.Write(this.ToStringHelper.ToStringWithCulture(member.MarshallName));

#line default
#line hidden
this.Write("\", targetDepth))\r\n {\r\n var unmarshaller = ");

#line 70 "C:\codebase\v3\AWSDotNetPublic\generator\ServiceClientGeneratorLib\Generators\Marshallers\JsonRPCExceptionUnmarshaller.tt"
#line 55 "C:\repos\aws-sdk-net-staging\generator\ServiceClientGeneratorLib\Generators\Marshallers\JsonRPCExceptionUnmarshaller.tt"
this.Write(this.ToStringHelper.ToStringWithCulture(member.DetermineTypeUnmarshallerInstantiate()));

#line default
#line hidden
this.Write(";\r\n unmarshalledObject.");

#line 71 "C:\codebase\v3\AWSDotNetPublic\generator\ServiceClientGeneratorLib\Generators\Marshallers\JsonRPCExceptionUnmarshaller.tt"
#line 56 "C:\repos\aws-sdk-net-staging\generator\ServiceClientGeneratorLib\Generators\Marshallers\JsonRPCExceptionUnmarshaller.tt"
this.Write(this.ToStringHelper.ToStringWithCulture(member.PropertyName));

#line default
#line hidden
this.Write(" = unmarshaller.Unmarshall(context);\r\n continue;\r\n " +
" }\r\n");

#line 74 "C:\codebase\v3\AWSDotNetPublic\generator\ServiceClientGeneratorLib\Generators\Marshallers\JsonRPCExceptionUnmarshaller.tt"
#line 59 "C:\repos\aws-sdk-net-staging\generator\ServiceClientGeneratorLib\Generators\Marshallers\JsonRPCExceptionUnmarshaller.tt"

}
}
Expand All @@ -206,7 +163,7 @@ public override string TransformText()
#line hidden
this.Write(" }\r\n \r\n return unmarshalledObject;\r\n }\r\n\r\n");

#line 83 "C:\codebase\v3\AWSDotNetPublic\generator\ServiceClientGeneratorLib\Generators\Marshallers\JsonRPCExceptionUnmarshaller.tt"
#line 68 "C:\repos\aws-sdk-net-staging\generator\ServiceClientGeneratorLib\Generators\Marshallers\JsonRPCExceptionUnmarshaller.tt"

this.AddStructureSingletonMethod();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,23 +38,8 @@ namespace <#=this.Config.Namespace #>.Model.Internal.MarshallTransformations
{
context.Read();

<#
if (this.Config.ServiceModel.IsAwsQueryCompatible)
{
GenerateAWSQueryCompatibleBlock();
#>
<#=this.UnmarshallerBaseName #> unmarshalledObject = new <#=this.UnmarshallerBaseName #>(errorResponse.Message, errorResponse.InnerException,
errorType, errorCode, errorResponse.RequestId, errorResponse.StatusCode);
<#
}
else
{
#>
<#=this.UnmarshallerBaseName #> unmarshalledObject = new <#=this.UnmarshallerBaseName #>(errorResponse.Message, errorResponse.InnerException,
errorResponse.Type, errorResponse.Code, errorResponse.RequestId, errorResponse.StatusCode);
<#
}
#>

int targetDepth = context.CurrentDepth;
while (context.ReadAtDepth(targetDepth))
Expand Down
Loading
Loading