summaryrefslogtreecommitdiff
path: root/lib/util.js
diff options
context:
space:
mode:
Diffstat (limited to 'lib/util.js')
-rw-r--r--lib/util.js29
1 files changed, 15 insertions, 14 deletions
diff --git a/lib/util.js b/lib/util.js
index d087c740b0..f6f99f82b4 100644
--- a/lib/util.js
+++ b/lib/util.js
@@ -21,18 +21,22 @@
'use strict';
-const errors = require('internal/errors');
+const {
+ codes: {
+ ERR_FALSY_VALUE_REJECTION,
+ ERR_INVALID_ARG_TYPE,
+ ERR_OUT_OF_RANGE
+ },
+ errnoException,
+ exceptionWithHostPort,
+ hideStackFrames
+} = require('internal/errors');
const {
format,
formatWithOptions,
inspect
} = require('internal/util/inspect');
const { debuglog } = require('internal/util/debuglog');
-const {
- ERR_FALSY_VALUE_REJECTION,
- ERR_INVALID_ARG_TYPE,
- ERR_OUT_OF_RANGE
-} = errors.codes;
const { validateNumber } = require('internal/validators');
const { TextDecoder, TextEncoder } = require('internal/encoding');
const { isBuffer } = require('buffer').Buffer;
@@ -158,19 +162,16 @@ function _extend(target, source) {
return target;
}
-function callbackifyOnRejected(reason, cb) {
+const callbackifyOnRejected = hideStackFrames((reason, cb) => {
// `!reason` guard inspired by bluebird (Ref: https://goo.gl/t5IS6M).
// Because `null` is a special error value in callbacks which means "no error
// occurred", we error-wrap so the callback consumer can distinguish between
// "the promise rejected with null" or "the promise fulfilled with undefined".
if (!reason) {
- const newReason = new ERR_FALSY_VALUE_REJECTION();
- newReason.reason = reason;
- reason = newReason;
- Error.captureStackTrace(reason, callbackifyOnRejected);
+ reason = new ERR_FALSY_VALUE_REJECTION(reason);
}
return cb(reason);
-}
+});
function callbackify(original) {
if (typeof original !== 'function') {
@@ -209,8 +210,8 @@ function getSystemErrorName(err) {
// Keep the `exports =` so that various functions can still be monkeypatched
module.exports = exports = {
- _errnoException: errors.errnoException,
- _exceptionWithHostPort: errors.exceptionWithHostPort,
+ _errnoException: errnoException,
+ _exceptionWithHostPort: exceptionWithHostPort,
_extend,
callbackify,
debuglog,