aws / aws-toolkit-vscode

Amazon Q, CodeCatalyst, Local Lambda debug, SAM/CFN syntax, ECS Terminal, AWS resources
https://marketplace.visualstudio.com/items?itemName=AmazonWebServices.amazon-q-vscode
Apache License 2.0
1.51k stars 436 forks source link

fix(auth): SyntaxError not being considered Network Error #5512

Closed nkomonen-amazon closed 2 months ago

nkomonen-amazon commented 2 months ago

Problem:

There were some previous changes that caused the existing implementation of a SyntaxError to not be considered a Network Error. And during token refresh we were seeing SyntaxErrors still appearing

Solution:

Create a single class which wraps a SyntaxError, called AwsClientResponseError. Under the hood of a SyntaxError is the real error that originates from a failed AWS SDK Client response, this is how we determine if it should be an AwsClientResponseError. This new class can only be created if given the correct SyntaxError instance to AwsClientResponseError.instanceIf().

Then we can simply check if an error matches by using instanceif AwsClientResponseError

Any existing code that was related to this scenario has all been centralized in to the AwsClientResponseError class.


License: I confirm that my contribution is made under the terms of the Apache 2.0 license.