@@ -29,6 +29,7 @@ const { createPromise, promiseResolve } = process.binding('util');
29
29
const async_hooks = require ( 'async_hooks' ) ;
30
30
const assert = require ( 'assert' ) ;
31
31
const util = require ( 'util' ) ;
32
+ const errors = require ( 'internal/errors' ) ;
32
33
const debug = util . debuglog ( 'timer' ) ;
33
34
const kOnTimeout = TimerWrap . kOnTimeout | 0 ;
34
35
const initTriggerId = async_hooks . initTriggerId ;
@@ -389,12 +390,13 @@ const unenroll = exports.unenroll = function(item) {
389
390
// Using existing objects as timers slightly reduces object overhead.
390
391
exports . enroll = function ( item , msecs ) {
391
392
if ( typeof msecs !== 'number' ) {
392
- throw new TypeError ( '"msecs" argument must be a number' ) ;
393
+ throw new errors . TypeError ( 'ERR_INVALID_ARG_TYPE' , 'msecs' ,
394
+ 'number' , msecs ) ;
393
395
}
394
396
395
397
if ( msecs < 0 || ! isFinite ( msecs ) ) {
396
- throw new RangeError ( '"msecs" argument must be ' +
397
- 'a non-negative finite number' ) ;
398
+ throw new errors . RangeError ( 'ERR_VALUE_OUT_OF_RANGE' , 'msecs' ,
399
+ 'a non-negative finite number' , msecs ) ;
398
400
}
399
401
400
402
// if this item was already in a list somewhere
@@ -418,7 +420,7 @@ exports.enroll = function(item, msecs) {
418
420
419
421
function setTimeout ( callback , after , arg1 , arg2 , arg3 ) {
420
422
if ( typeof callback !== 'function' ) {
421
- throw new TypeError ( '"callback" argument must be a function ' ) ;
423
+ throw new errors . TypeError ( 'ERR_INVALID_CALLBACK ' ) ;
422
424
}
423
425
424
426
var len = arguments . length ;
@@ -515,7 +517,7 @@ const clearTimeout = exports.clearTimeout = function(timer) {
515
517
516
518
exports . setInterval = function ( callback , repeat , arg1 , arg2 , arg3 ) {
517
519
if ( typeof callback !== 'function' ) {
518
- throw new TypeError ( '"callback" argument must be a function ' ) ;
520
+ throw new errors . TypeError ( 'ERR_INVALID_CALLBACK ' ) ;
519
521
}
520
522
521
523
var len = arguments . length ;
@@ -810,7 +812,7 @@ function Immediate() {
810
812
811
813
function setImmediate ( callback , arg1 , arg2 , arg3 ) {
812
814
if ( typeof callback !== 'function' ) {
813
- throw new TypeError ( '"callback" argument must be a function ' ) ;
815
+ throw new errors . TypeError ( 'ERR_INVALID_CALLBACK ' ) ;
814
816
}
815
817
816
818
var i , args ;
0 commit comments