return deprecated;
};
+
+exports.decorateErrorStack = function decorateErrorStack(err) {
+ if (!(exports.isError(err) && err.stack))
+ return;
+
+ const arrow = exports.getHiddenValue(err, 'arrowMessage');
+
+ if (arrow)
+ err.stack = arrow + err.stack;
+};
+
+exports.isError = function isError(e) {
+ return exports.objectToString(e) === '[object Error]' || e instanceof Error;
+};
+
+exports.objectToString = function objectToString(o) {
+ return Object.prototype.toString.call(o);
+};
'use strict';
const internalModule = require('internal/module');
+const internalUtil = require('internal/util');
const util = require('util');
const inherits = util.inherits;
const Stream = require('stream');
self._domain.on('error', function(e) {
debug('domain error');
const top = replMap.get(self);
- util.decorateErrorStack(e);
+ internalUtil.decorateErrorStack(e);
top.outputStream.write((e.stack || e) + '\n');
top.lineParser.reset();
top.bufferedCommand = '';
const internalUtil = require('internal/util');
const binding = process.binding('util');
+const isError = internalUtil.isError;
+const objectToString = internalUtil.objectToString;
+
var Debug;
const formatRegExp = /%[sdj%]/g;
}
exports.isDate = isDate;
-function isError(e) {
- return objectToString(e) === '[object Error]' || e instanceof Error;
-}
exports.isError = isError;
function isFunction(arg) {
exports.isBuffer = Buffer.isBuffer;
-function objectToString(o) {
- return Object.prototype.toString.call(o);
-}
-
function pad(n) {
return n < 10 ? '0' + n.toString(10) : n.toString(10);
}
return ex;
};
-
-
-exports.decorateErrorStack = function(err) {
- if (!(isError(err) && err.stack))
- return;
-
- const arrow = internalUtil.getHiddenValue(err, 'arrowMessage');
-
- if (arrow)
- err.stack = arrow + err.stack;
-};
+// Flags: --expose_internals
'use strict';
const common = require('../common');
const assert = require('assert');
-const util = require('util');
+const internalUtil = require('internal/util');
assert.doesNotThrow(function() {
- util.decorateErrorStack();
- util.decorateErrorStack(null);
- util.decorateErrorStack(1);
- util.decorateErrorStack(true);
+ internalUtil.decorateErrorStack();
+ internalUtil.decorateErrorStack(null);
+ internalUtil.decorateErrorStack(1);
+ internalUtil.decorateErrorStack(true);
});
// Verify that a stack property is not added to non-Errors
const obj = {};
-util.decorateErrorStack(obj);
+internalUtil.decorateErrorStack(obj);
assert.strictEqual(obj.stack, undefined);
// Verify that the stack is decorated when possible
} catch (e) {
err = e;
assert(!/var foo bar;/.test(err.stack));
- util.decorateErrorStack(err);
+ internalUtil.decorateErrorStack(err);
}
assert(/var foo bar;/.test(err.stack));
// Verify that the stack is unchanged when there is no arrow message
err = new Error('foo');
const originalStack = err.stack;
-util.decorateErrorStack(err);
+internalUtil.decorateErrorStack(err);
assert.strictEqual(originalStack, err.stack);