better error message for bad args

This commit is contained in:
Olivier Gagnon 2021-12-12 13:30:28 -05:00
parent cdeabfec0e
commit dea8abef1d
3 changed files with 7 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

@ -651,9 +651,12 @@ export function runScriptFromScript(
return 0;
}
args.forEach((arg) => {
args.forEach((arg, i) => {
if (typeof arg !== "string" && typeof arg !== "number" && typeof arg !== "boolean")
throw new Error("Only strings, numbers, and booleans can be passed as arguments to otherscripts.");
throw new Error(
"Only strings, numbers, and booleans can be passed as arguments to other scripts.\n" +
`${scriptname} argument index ${i} is of type ${typeof arg} and value ${JSON.stringify(arg)}`,
);
});
// Check if the script is already running