fix: don't fatal Explorer when there's a 'failed' type message at the top level (#24868)

This commit is contained in:
Steven Luscher 2022-04-30 18:27:42 -07:00 committed by GitHub
parent 7f987722bf
commit 06ffd9009e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 15 additions and 3 deletions

View File

@ -24,10 +24,22 @@ export function parseProgramLogs(
): InstructionLogs[] {
let depth = 0;
let prettyLogs: InstructionLogs[] = [];
const prefixBuilder = (depth: number) => {
const prefix = new Array(depth - 1).fill("\u00A0\u00A0").join("");
function prefixBuilder(
// Indent level starts at 1.
indentLevel: number
) {
let prefix;
if (indentLevel <= 0) {
console.warn(
`Tried to build a prefix for a program log at indent level \`${indentLevel}\`. ` +
"Logs should only ever be built at indent level 1 or higher."
);
prefix = "";
} else {
prefix = new Array(indentLevel - 1).fill("\u00A0\u00A0").join("");
}
return prefix + "> ";
};
}
let prettyError;
if (error) {