Skip to content
This repository was archived by the owner on Sep 9, 2024. It is now read-only.

Commit 2a842ae

Browse files
committed
feat: output 404 error if file not found
1 parent 2a29b8d commit 2a842ae

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

src/middlewares/localFs/index.ts

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -137,8 +137,16 @@ export function localFsMiddleware({ repoPath, logger }: FsOptions) {
137137
break;
138138
}
139139
}
140-
} catch (e: any) {
141-
logger.error(`Error handling ${JSON.stringify(req.body)}: ${e.message}`);
140+
} catch (e: unknown) {
141+
if (e instanceof Error) {
142+
logger.error(`Error handling ${JSON.stringify(req.body)}: ${e.message}`);
143+
144+
if (e.message.startsWith('ENOENT: no such file or directory')) {
145+
res.status(404).json({ error: 'Not found' });
146+
return;
147+
}
148+
}
149+
142150
res.status(500).json({ error: 'Unknown error' });
143151
}
144152
};

0 commit comments

Comments
 (0)