@@ -29,6 +29,7 @@ const { createPromise, promiseResolve } = process.binding('util');
2929const async_hooks = require ( 'async_hooks' ) ;
3030const assert = require ( 'assert' ) ;
3131const util = require ( 'util' ) ;
32+ const errors = require ( 'internal/errors' ) ;
3233const debug = util . debuglog ( 'timer' ) ;
3334const kOnTimeout = TimerWrap . kOnTimeout | 0 ;
3435const initTriggerId = async_hooks . initTriggerId ;
@@ -389,12 +390,13 @@ const unenroll = exports.unenroll = function(item) {
389390// Using existing objects as timers slightly reduces object overhead.
390391exports . enroll = function ( item , msecs ) {
391392 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 ) ;
393395 }
394396
395397 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 ) ;
398400 }
399401
400402 // if this item was already in a list somewhere
@@ -418,7 +420,7 @@ exports.enroll = function(item, msecs) {
418420
419421function setTimeout ( callback , after , arg1 , arg2 , arg3 ) {
420422 if ( typeof callback !== 'function' ) {
421- throw new TypeError ( '"callback" argument must be a function ' ) ;
423+ throw new errors . TypeError ( 'ERR_INVALID_CALLBACK ' ) ;
422424 }
423425
424426 var len = arguments . length ;
@@ -515,7 +517,7 @@ const clearTimeout = exports.clearTimeout = function(timer) {
515517
516518exports . setInterval = function ( callback , repeat , arg1 , arg2 , arg3 ) {
517519 if ( typeof callback !== 'function' ) {
518- throw new TypeError ( '"callback" argument must be a function ' ) ;
520+ throw new errors . TypeError ( 'ERR_INVALID_CALLBACK ' ) ;
519521 }
520522
521523 var len = arguments . length ;
@@ -810,7 +812,7 @@ function Immediate() {
810812
811813function setImmediate ( callback , arg1 , arg2 , arg3 ) {
812814 if ( typeof callback !== 'function' ) {
813- throw new TypeError ( '"callback" argument must be a function ' ) ;
815+ throw new errors . TypeError ( 'ERR_INVALID_CALLBACK ' ) ;
814816 }
815817
816818 var i , args ;
0 commit comments