diff options
author | Michaël Zasso <targos@protonmail.com> | 2018-03-05 00:16:24 +0300 |
---|---|---|
committer | Michaël Zasso <targos@protonmail.com> | 2018-03-07 16:54:38 +0300 |
commit | 1d2fd8b65bacaf4401450edc8ed529106cbcfc67 (patch) | |
tree | dd6230e888c69ef3dc1b19de1ea8f9de7a81fd63 /lib/internal/async_hooks.js | |
parent | cb5f9a6d871f6b2e0da8fa72dc2e91fb37ef9713 (diff) |
lib: port remaining errors to new system
PR-URL: https://github.com/nodejs/node/pull/19137
Reviewed-By: Anatoli Papirovski <apapirovski@mac.com>
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com>
Diffstat (limited to 'lib/internal/async_hooks.js')
-rw-r--r-- | lib/internal/async_hooks.js | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/lib/internal/async_hooks.js b/lib/internal/async_hooks.js index 44be2990d6a..72d74243d8c 100644 --- a/lib/internal/async_hooks.js +++ b/lib/internal/async_hooks.js @@ -1,6 +1,9 @@ 'use strict'; -const errors = require('internal/errors'); +const { + ERR_ASYNC_TYPE, + ERR_INVALID_ASYNC_ID +} = require('internal/errors').codes; const async_wrap = process.binding('async_wrap'); /* async_hook_fields is a Uint32Array wrapping the uint32_t array of * Environment::AsyncHooks::fields_[]. Each index tracks the number of active @@ -115,7 +118,7 @@ function validateAsyncId(asyncId, type) { if (async_hook_fields[kCheck] <= 0) return; if (!Number.isSafeInteger(asyncId) || asyncId < -1) { - fatalError(new errors.RangeError('ERR_INVALID_ASYNC_ID', type, asyncId)); + fatalError(new ERR_INVALID_ASYNC_ID(type, asyncId)); } } @@ -313,7 +316,7 @@ function emitInitScript(asyncId, type, triggerAsyncId, resource) { validateAsyncId(triggerAsyncId, 'triggerAsyncId'); if (async_hook_fields[kCheck] > 0 && (typeof type !== 'string' || type.length <= 0)) { - throw new errors.TypeError('ERR_ASYNC_TYPE', type); + throw new ERR_ASYNC_TYPE(type); } // Short circuit all checks for the common case. Which is that no hooks have |