Skip to content

Commit

Permalink
view async error
Browse files Browse the repository at this point in the history
  • Loading branch information
developeramarkumar committed Aug 21, 2022
1 parent 191a098 commit 6fe9257
Showing 1 changed file with 13 additions and 9 deletions.
22 changes: 13 additions & 9 deletions view/viewEngine.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,15 +30,19 @@ class View {
Object.assign(data, context)

app.view.engine(http.response.__viewEngine).renderFile(file, data, async (data) => {
data = await data
if (typeof data == 'object' && data instanceof Promise == false) {
return next(new ViewException(data))
}
try {
http.response.send(data, status)
} catch (e) {
next(e)
}
Promise.resolve(data)
.then(res => {
if (typeof res == 'object' && res instanceof Promise == false) {
throw (new ViewException(res))
}
http.response.send(res, status)



})
.catch(e => {
next(e)
})

})
return http.response
Expand Down

0 comments on commit 6fe9257

Please sign in to comment.