mirror of
https://github.com/laosb/ghos3.git
synced 2025-04-30 15:41:08 +00:00
Handle NoSuchKey error gracefully
This commit is contained in:
parent
ee4bbfca75
commit
8036b3aec2
1 changed files with 7 additions and 2 deletions
|
@ -196,12 +196,17 @@ class S3Storage extends StorageBase {
|
|||
const stream = output.Body as Readable
|
||||
stream.pipe(res)
|
||||
} catch (err) {
|
||||
res.status(404)
|
||||
next(err)
|
||||
if (err.name === 'NoSuchKey') {
|
||||
res.status(404).send('Image not found');
|
||||
} else {
|
||||
res.status(500);
|
||||
next(err);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
async read(options: ReadOptions = { path: '' }) {
|
||||
let path = (options.path || '').replace(/\/$|\\$/, '')
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue