Files
node/test/fixtures/uncaught-exceptions/callbackify2.js
T
Refael Ackermann af3aa682ac util: add callbackify
Add `util.callbackify(function)` for creating callback style functions
from functions returning a `Thenable`

PR-URL: https://github.com/nodejs/node/pull/12712
Fixes: https://github.com/nodejs/CTC/issues/109
Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com>
Reviewed-By: Teddy Katz <teddy.katz@gmail.com>
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Timothy Gu <timothygu99@gmail.com>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
2017-06-10 22:49:28 -04:00

23 lines
530 B
JavaScript

'use strict';
// Used to test the `uncaughtException` err object
const assert = require('assert');
const { callbackify } = require('util');
{
const sentinel = new Error(__filename);
process.once('uncaughtException', (err) => {
assert.strictEqual(err, sentinel);
// Calling test will use `stdout` to assert value of `err.message`
console.log(err.message);
});
async function fn() {
return await Promise.reject(sentinel);
}
const cbFn = callbackify(fn);
cbFn((err, ret) => assert.ifError(err));
}