Skip to content

Commit

Permalink
Show the error metadata
Browse files Browse the repository at this point in the history
  • Loading branch information
IonicaBizau committed Feb 12, 2023
1 parent bccd38a commit a0f790c
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions lib/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,7 @@ module.exports = function bloggifyFlexibleRouter (config, cb) {
Bloggify.render(ctx, cUri.view, data)
})
}).catch(error => {
error.status = error.status || 500
error.status = error.status || error.statusCode || 500

const data = {
statusCode: error.status
Expand Down Expand Up @@ -237,7 +237,7 @@ module.exports = function bloggifyFlexibleRouter (config, cb) {
data && (delete data.statusCode)
ctx.end(data, status)
}).catch(error => {
error.status = error.status || 500
error.status = error.status || error.statusCode || 500

const data = {
statusCode: error.status
Expand All @@ -254,6 +254,10 @@ module.exports = function bloggifyFlexibleRouter (config, cb) {
res.code = error.code
}

if (error.metadata) {
res.metadata = error.metadata
}

ctx.end(res, data.statusCode)
return
}
Expand Down

0 comments on commit a0f790c

Please sign in to comment.