mirror of
https://github.com/Permissionless-Software-Foundation/bch-dex.git
synced 2026-09-22 01:02:00 -07:00
Fix error handling for DEL method
This commit is contained in:
@@ -87,15 +87,23 @@ router.put('/:id',
|
||||
router.delete('/:id',
|
||||
ensureUser,
|
||||
async (ctx) => {
|
||||
const user = await User.findById(ctx.params.id)
|
||||
try {
|
||||
const user = await User.findById(ctx.params.id)
|
||||
if (!user) {
|
||||
ctx.throw(404)
|
||||
}
|
||||
|
||||
if (!user) {
|
||||
ctx.throw(404)
|
||||
await user.remove()
|
||||
|
||||
ctx.body = 200
|
||||
} catch (err) {
|
||||
|
||||
if (err === 404 || err.name === 'CastError') {
|
||||
ctx.throw(404)
|
||||
}
|
||||
|
||||
ctx.throw(500)
|
||||
}
|
||||
|
||||
await user.remove()
|
||||
|
||||
ctx.body = 200
|
||||
}
|
||||
)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user