From 1d2fd8b65bacaf4401450edc8ed529106cbcfc67 Mon Sep 17 00:00:00 2001 From: Michaƫl Zasso Date: Sun, 4 Mar 2018 22:16:24 +0100 Subject: lib: port remaining errors to new system PR-URL: https://github.com/nodejs/node/pull/19137 Reviewed-By: Anatoli Papirovski Reviewed-By: Ruben Bridgewater Reviewed-By: James M Snell Reviewed-By: Joyee Cheung --- lib/internal/timers.js | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) (limited to 'lib/internal/timers.js') diff --git a/lib/internal/timers.js b/lib/internal/timers.js index 8c1a87a65f..26fc3f941b 100644 --- a/lib/internal/timers.js +++ b/lib/internal/timers.js @@ -10,7 +10,11 @@ const { const async_id_symbol = Symbol('asyncId'); const trigger_async_id_symbol = Symbol('triggerId'); -const errors = require('internal/errors'); +const { + ERR_INVALID_ARG_TYPE, + ERR_INVALID_CALLBACK, + ERR_OUT_OF_RANGE +} = require('internal/errors').codes; // Timeout values > TIMEOUT_MAX are set to 1. const TIMEOUT_MAX = 2 ** 31 - 1; @@ -94,7 +98,7 @@ Timeout.prototype[refreshFnSymbol] = function refresh() { function setUnrefTimeout(callback, after, arg1, arg2, arg3) { // Type checking identical to setTimeout() if (typeof callback !== 'function') { - throw new errors.TypeError('ERR_INVALID_CALLBACK'); + throw new ERR_INVALID_CALLBACK(); } let i, args; @@ -127,13 +131,11 @@ function setUnrefTimeout(callback, after, arg1, arg2, arg3) { // Type checking used by timers.enroll() and Socket#setTimeout() function validateTimerDuration(msecs) { if (typeof msecs !== 'number') { - throw new errors.TypeError('ERR_INVALID_ARG_TYPE', 'msecs', - 'number', msecs); + throw new ERR_INVALID_ARG_TYPE('msecs', 'number', msecs); } if (msecs < 0 || !isFinite(msecs)) { - throw new errors.RangeError('ERR_OUT_OF_RANGE', 'msecs', - 'a non-negative finite number', msecs); + throw new ERR_OUT_OF_RANGE('msecs', 'a non-negative finite number', msecs); } // Ensure that msecs fits into signed int32 -- cgit v1.2.3