Skip to content

Commit

Permalink
Error handling
Browse files Browse the repository at this point in the history
  • Loading branch information
ledyba committed Nov 16, 2024
1 parent 6a6b20d commit eef1236
Showing 1 changed file with 11 additions and 9 deletions.
20 changes: 11 additions & 9 deletions server/src/controller/both/EntityController.ts
Original file line number Diff line number Diff line change
Expand Up @@ -70,23 +70,25 @@ export default class EntityController {
'maxAge': 24 * 3600 * 7,
};
const sendResult = await send(req.raw, encodeURI(entityPath), sendOption);
if (sendResult.type === 'directory') {
return reply
.code(500)
.type('text/plain;charset=UTF-8')
.send(`[BUG] Invalid SendResult. Directory is specified, please give me a filepath.`);
}
if (sendResult.type === 'error') {
if (sendResult.type !== 'file') {
let msg;
switch (sendResult.type) {
case 'error':
msg = `[BUG] Invalid SendResult. Error: ${sendResult.metadata.error}`;
break;
case 'directory':
msg = `[BUG] Invalid SendResult. Directory is specified, please give me a filepath.`;
}
return reply
.code(500)
.type('text/plain;charset=UTF-8')
.send(`[BUG] Invalid SendResult. Error: ${sendResult.metadata.error}`);
.send(msg);
}
if (sendResult.statusCode !== 200) {
return reply
.code(sendResult.statusCode)
.type('text/plain;charset=UTF-8')
.send(`[BUG] Failed to make stream`);
.send(`[BUG] Failed to make valid stream.`);
}
const stream = sendResult.stream;

Expand Down

0 comments on commit eef1236

Please sign in to comment.