Skip to content
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
fix nits
  • Loading branch information
yorkie committed Nov 17, 2015
commit 250e4a1faf5301ffb43aab756120ae26a3bd62f3
2 changes: 1 addition & 1 deletion src/node.js
Original file line number Diff line number Diff line change
Expand Up @@ -490,7 +490,7 @@
if (process._exiting)
return;
if (typeof callback !== 'function')
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would move this if above the previous if for a more consistent throwing experience.

throw new Error('callback is not a function');
throw new TypeError('callback is not a function');

var args;
if (arguments.length > 1) {
Expand Down
25 changes: 19 additions & 6 deletions test/parallel/test-next-tick-errors.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,15 +20,28 @@ process.nextTick(function() {
order.push('C');
});

try {
process.nextTick();
} catch (e) {
// should handle this error at try...catch
if (!e) {
assert.fail();
assert.throws(
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This assertion should be removed because having just process.nextTick (no parens/uninvoked) is never going to throw, it will always return the function itself.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you want to test the "same" thing as process.nextTick(), you could add testNextTickWith().

function () {
process.nextTick
}
);

function testNextTickWith(val) {
assert.throws(
function() {
process.nextTick(val);
},
TypeError
);
}

testNextTickWith(false);
testNextTickWith(true);
testNextTickWith(1);
testNextTickWith('str');
testNextTickWith({});
testNextTickWith([]);

process.on('uncaughtException', function() {
if (!exceptionHandled) {
exceptionHandled = true;
Expand Down