Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function callWithCbOrNextTick (func, cb, context) {
- if (this && this._server) {
- context = this._server
- }
- if (func.length === 0) {
- if (this._error) throw this._error
- func()
- process.nextTick(cb)
- } else if (func.length === 1) {
- func(this._error)
- process.nextTick(cb)
- } else if (func.length === 2) {
- func(this._error, cb)
- } else {
- func(this.rerror, context, cb)
- }
- // with this the error will appear just in the next after/ready callback
- this._error = null
- }
- ___________________________
- const app = boot(server) [19/736]
- app.use(function (s, opts, done) {
- done(new Error('err'))
- })
- app.after(function (err, cb) {
- t.ok(err instanceof Error)
- t.is(err.message, 'err')
- cb()
- })
- app.ready(function (err) {
- t.error(err)
- })
- })
- test('error should come in the first ready', (t) => {
- t.plan(2)
- const server = { my: 'server' }
- const app = boot(server)
- app.use(function (s, opts, done) {
- done(new Error('err'))
- })
- app.ready(function (err) {
- t.ok(err instanceof Error)
- t.is(err.message, 'err')
- })
- })
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement