const Promise = require('bluebird')
const coWrap = require('express_cowrap')
const express = require('express')
let app = express()
app.get('/promise', coWrap(function (req, res) {
return Promise.reject('error message')
})
app.get('/sync', coWrap(function (req, res) {
throw new Error('error message')
}))
app.get('/generators', coWrap(function* (req, res) {
let data = yield database.query()
yield Promise.delay(20)
throw new Error('error message')
res.status(200).send({ message: "You won't see me!" })
}))
app.use(function errorHandler(err, req, res, next) {
console.log('[Error happened]', err)
res.status(500).send({ error: (err.message || err) })
})