Merge pull request #1750 from danielyxie/dev

fix tprintf catching errors
This commit is contained in:
hydroflame 2021-11-19 22:58:56 -05:00 committed by GitHub
commit 41592a199a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 8 additions and 4 deletions

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

@ -690,6 +690,9 @@ export function NetscriptFunctions(workerScript: WorkerScript): NS {
Terminal.print(`${workerScript.scriptRef.filename}: ${str}`);
},
tprintf: function (format: any, ...args: any): any {
if (typeof format !== "string") {
throw makeRuntimeErrorMsg("tprintf", "First argument must be string for the format.");
}
const str = vsprintf(format, args);
if (str.startsWith("ERROR") || str.startsWith("FAIL")) {

@ -3664,9 +3664,10 @@ export interface NS extends Singularity {
* @remarks
* RAM cost: 0 GB
*
* @param format - format of the message
* @param msg - Value to be printed.
*/
tprintf(msg: any): void;
tprintf(format: string, ...values: any[]): void;
/**
* Clears the scripts logs.