Skip to content

Commit fad46a4

Browse files
authored
wrap inotify errors in AmplifyUserError (#2575)
* wrap inotify errors in AmplifyUserError * fix lint
1 parent 435c79b commit fad46a4

File tree

4 files changed

+32
-0
lines changed

4 files changed

+32
-0
lines changed

.changeset/mighty-kids-thank.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@aws-amplify/platform-core': patch
3+
---
4+
5+
wrap inotify errors in AmplifyUserError

.eslint_dictionary.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,7 @@
8888
"idps",
8989
"implementors",
9090
"inheritdoc",
91+
"inotify",
9192
"instanceof",
9293
"interop",
9394
"invokable",

packages/platform-core/src/errors/amplify_error.test.ts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -316,4 +316,15 @@ void describe('AmplifyError.fromError', async () => {
316316
`Failed the test for error ${error.message}`
317317
);
318318
});
319+
void it('wraps InsufficientInotifyWatchersError in AmplifyUserError when system has reached the limit of inotify watchers', () => {
320+
const error = new Error(
321+
`Error: inotify_add_watch on '/some/path' failed: No space left on device`
322+
);
323+
const actual = AmplifyError.fromError(error);
324+
assert.ok(
325+
AmplifyError.isAmplifyError(actual) &&
326+
actual.name === 'InsufficientInotifyWatchersError',
327+
`Failed the test for error ${error.message}`
328+
);
329+
});
319330
});

packages/platform-core/src/errors/amplify_error.ts

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -194,6 +194,17 @@ export abstract class AmplifyError<T extends string = string> extends Error {
194194
error
195195
);
196196
}
197+
if (error instanceof Error && isInotifyError(error)) {
198+
return new AmplifyUserError(
199+
'InsufficientInotifyWatchersError',
200+
{
201+
message: error.message,
202+
resolution:
203+
'There appears to be an insufficient number of inotify watchers. To increase the amount of inotify watchers, change the `fs.inotify.max_user_watches` setting in your system config files to a higher value.',
204+
},
205+
error
206+
);
207+
}
197208
return new AmplifyFault(
198209
'UnknownFault',
199210
{
@@ -330,6 +341,10 @@ const isOutOfMemoryError = (err?: Error): boolean => {
330341
);
331342
};
332343

344+
const isInotifyError = (err?: Error): boolean => {
345+
return !!err && err.message.includes('inotify_add_watch');
346+
};
347+
333348
/**
334349
* Amplify exception classifications
335350
*/

0 commit comments

Comments
 (0)