mirror of
https://github.com/comatory/fb2iCal
synced 2025-06-05 22:09:25 +02:00
add JSON response for errors when using JS
This commit is contained in:
@@ -1,7 +1,19 @@
|
||||
const FBURLError = () => new Error('Not a valid Facebook URL!')
|
||||
|
||||
const sendJSON = (req) => {
|
||||
return req.accepts().includes('application/json')
|
||||
}
|
||||
|
||||
const genericErrorHandler = (err, req, res, next) => {
|
||||
console.error(err.stack)
|
||||
|
||||
if (sendJSON(req)) {
|
||||
res
|
||||
.status(500)
|
||||
.send({ error: err.toString() })
|
||||
return
|
||||
}
|
||||
|
||||
res
|
||||
.status(500)
|
||||
.render('error', { error: err.toString() })
|
||||
|
Reference in New Issue
Block a user