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

refactor(auth): redo `DiskCacheError` with proper context #5558

Closed nkomonen-amazon closed 2 months ago

nkomonen-amazon commented 2 months ago

Problem:

The original implementation of DiskCacheError can be simplified and still achieve it's original purpose.

Solution:

During token refresh we eventually write to the disk cache. Sometimes this process fails due to filesystem errors.

We dont need to care about the actual file system error, but only that the error came during a DiskCache operation (i.e when it attempts to save the token to disk)

So instead, at the root of where the disk cache errors ocurr, we will wrap caught errors in a DiskCacheError. This adds context to the error and allows anything upstream to specifically check for that context, instead of needing to parse the error to see if it was filesystem related.

Additionally not all file system errors were guaranteed to come from the disk cache, so this change allows us to target the right errors.

Signed-off-by: Nikolas Komonen nkomonen@amazon.com


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