summaryrefslogtreecommitdiff
path: root/ext/console/01_console.js
diff options
context:
space:
mode:
Diffstat (limited to 'ext/console/01_console.js')
-rw-r--r--ext/console/01_console.js43
1 files changed, 14 insertions, 29 deletions
diff --git a/ext/console/01_console.js b/ext/console/01_console.js
index 31431f120..dbbc549ca 100644
--- a/ext/console/01_console.js
+++ b/ext/console/01_console.js
@@ -161,6 +161,7 @@ const styles = {
// TODO(BridgeAR): Highlight regular expressions properly.
regexp: "red",
module: "underline",
+ internalError: "red",
};
const defaultFG = 39;
@@ -1022,7 +1023,6 @@ function formatRaw(ctx, value, recurseTimes, typedArray, proxyDetails) {
ArrayPrototypePush(ctx.seen, value);
ctx.currentDepth = recurseTimes;
let output;
- const indentationLvl = ctx.indentationLvl;
try {
output = formatter(ctx, value, recurseTimes);
for (i = 0; i < keys.length; i++) {
@@ -1034,13 +1034,12 @@ function formatRaw(ctx, value, recurseTimes, typedArray, proxyDetails) {
if (protoProps !== undefined) {
ArrayPrototypePushApply(output, protoProps);
}
- } catch (err) {
- const constructorName = StringPrototypeSlice(
- getCtxStyle(value, constructor, tag),
- 0,
- -1,
+ } catch (error) {
+ // TODO(wafuwafu13): Implement stack overflow check
+ return ctx.stylize(
+ `[Internal Formatting Error] ${error.stack}`,
+ "internalError",
);
- return handleMaxCallStackSize(ctx, err, constructorName, indentationLvl);
}
if (ctx.circular !== undefined) {
@@ -1658,8 +1657,14 @@ const PromiseState = {
function formatPromise(ctx, value, recurseTimes) {
let output;
- // TODO(wafuwafu13): Implement
- const { 0: state, 1: result } = core.getPromiseDetails(value);
+ let opResult;
+ // This op will fail for non-promises, but we get here for some promise-likes.
+ try {
+ opResult = core.getPromiseDetails(value);
+ } catch {
+ return [ctx.stylize("<unknown>", "special")];
+ }
+ const { 0: state, 1: result } = opResult;
if (state === PromiseState.Pending) {
output = [ctx.stylize("<pending>", "special")];
} else {
@@ -1770,26 +1775,6 @@ function formatProperty(
return `${name}:${extra}${str}`;
}
-function handleMaxCallStackSize(
- _ctx,
- _err,
- _constructorName,
- _indentationLvl,
-) {
- // TODO(wafuwafu13): Implement
- // if (isStackOverflowError(err)) {
- // ctx.seen.pop();
- // ctx.indentationLvl = indentationLvl;
- // return ctx.stylize(
- // `[${constructorName}: Inspection interrupted ` +
- // 'prematurely. Maximum call stack size exceeded.]',
- // 'special'
- // );
- // }
- // /* c8 ignore next */
- // assert.fail(err.stack);
-}
-
const colorRegExp = new SafeRegExp("\u001b\\[\\d\\d?m", "g");
function removeColors(str) {
return StringPrototypeReplace(str, colorRegExp, "");