Skip to content

Commit

Permalink
feat(exc): Print Tact/Misti version on error
Browse files Browse the repository at this point in the history
  • Loading branch information
jubnzv committed Sep 20, 2024
1 parent 730f6b0 commit d3e81f1
Showing 1 changed file with 16 additions and 3 deletions.
19 changes: 16 additions & 3 deletions src/internals/exceptions.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { TACT_VERSION, MISTI_VERSION } from "../version";
import { AstNode, SrcInfo } from "@tact-lang/compiler/dist/grammar/ast";
import * as fs from "fs";
import JSONbig from "json-bigint";
Expand Down Expand Up @@ -38,6 +39,7 @@ export class TactException {
tactStack,
SEPARATOR,
getCmd(),
getVersions(),
].join("\n");
const shortMsg = [errorKind, error.message].join("\n");
// Dump full message to the file.
Expand Down Expand Up @@ -85,10 +87,12 @@ export class InternalException {
? []
: [`${SEPARATOR}AST node:\n${JSONbig.stringify(node, null, 2)}`]),
SEPARATOR,
getCmd(),
getCurrentStackTrace(),
SEPARATOR,
getCmd(),
getVersions(),
].join("\n");
const shortMsg = [errorKind, msg].join("\n");
const shortMsg = [errorKind, msg, getVersions()].join("\n");
if (!generateReport) {
return new Error(shortMsg);
}
Expand Down Expand Up @@ -145,11 +149,20 @@ function getCurrentStackTrace(): string {
}
}

/** Returns the command used to execute code, like: "$0 $@". */
/**
* @returns Command used to execute code, like: "$0 $@".
*/
function getCmd(): string {
return `Command: ${process.argv.join(" ")}`;
}

/**
* @returns Tact and Misti versions string.
*/
function getVersions(): string {
return `Using Tact ${TACT_VERSION}; Misti ${MISTI_VERSION}`;
}

/**
* Saves the comprehensive information on this error to the text file that is supposed to be published in the issue.
* @param fullMsg A error message to save to file.
Expand Down

0 comments on commit d3e81f1

Please sign in to comment.