Skip to content

Commit 8e1ceca

Browse files
authored
fix(ux): added error message for ENOTDIR (#26128)
1 parent b0ffa3b commit 8e1ceca

2 files changed

Lines changed: 16 additions & 0 deletions

File tree

packages/core/src/utils/fsErrorMessages.test.ts

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -152,6 +152,19 @@ describe('getFsErrorMessage', () => {
152152
expected:
153153
'Operation timed out. The network connection or filesystem operation took too long.',
154154
},
155+
{
156+
code: 'ENOTDIR',
157+
message: 'ENOTDIR: not a directory',
158+
path: '/some/file.txt/inner',
159+
expected:
160+
"Not a directory: '/some/file.txt/inner'. Check if the path is correct and that all parent components are directories.",
161+
},
162+
{
163+
code: 'ENOTDIR',
164+
message: 'ENOTDIR: not a directory',
165+
expected:
166+
'Not a directory. Check if the path is correct and that all parent components are directories.',
167+
},
155168
];
156169

157170
it.each(testCases)(

packages/core/src/utils/fsErrorMessages.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,9 @@ const errorMessageGenerators: Record<string, (path?: string) => string> = {
5252
'Connection reset by peer. The network connection was unexpectedly closed.',
5353
ETIMEDOUT: () =>
5454
'Operation timed out. The network connection or filesystem operation took too long.',
55+
ENOTDIR: (path) =>
56+
(path ? `Not a directory: '${path}'. ` : 'Not a directory. ') +
57+
'Check if the path is correct and that all parent components are directories.',
5558
};
5659

5760
/**

0 commit comments

Comments
 (0)