diff --git a/packages/aws-cdk/lib/api/aws-auth/account-cache.ts b/packages/aws-cdk/lib/api/aws-auth/account-cache.ts index 543dbf15d1188..aea859646751f 100644 --- a/packages/aws-cdk/lib/api/aws-auth/account-cache.ts +++ b/packages/aws-cdk/lib/api/aws-auth/account-cache.ts @@ -81,7 +81,7 @@ export class AccountAccessKeyCache { } catch (e: any) { // File doesn't exist or is not readable. This is a cache, // pretend we successfully loaded an empty map. - if (e.name === 'ENOENT' || e.name === 'EACCES') { + if (e.code === 'ENOENT' || e.code === 'EACCES') { return {}; } // File is not JSON, could be corrupted because of concurrent writes. @@ -100,7 +100,7 @@ export class AccountAccessKeyCache { } catch (e: any) { // File doesn't exist or file/dir isn't writable. This is a cache, // if we can't write it then too bad. - if (e.name === 'ENOENT' || e.name === 'EACCES' || e.name === 'EROFS') { + if (e.code === 'ENOENT' || e.code === 'EACCES' || e.code === 'EROFS') { return; } throw e; diff --git a/packages/aws-cdk/test/account-cache.test.ts b/packages/aws-cdk/test/account-cache.test.ts index 0c8334136c6f1..5c338fd42e3e1 100644 --- a/packages/aws-cdk/test/account-cache.test.ts +++ b/packages/aws-cdk/test/account-cache.test.ts @@ -1,4 +1,3 @@ -/* eslint-disable import/order */ import * as path from 'path'; import * as fs from 'fs-extra'; import { withMocked } from './util';