我在sample.ts(打字稿)中有以下代码,其中 exe 始终返回 0(成功)、1(失败)或 2(未知错误)的退出代码。我希望validateFunc调用正确返回退出代码并进入下一行,但它会转到非零退出代码的 catch 块。知道是什么导致了这种行为吗?
try
{
...{some code}
let exitCode = await validateFunc("sample1", "sample2");
if(exitcode!=0)
{
// expecting toland here when tool returns non-zero exit code
}
..{some code here}
}
catch (error)
{
// Above call to validateFunc lands here for non-zero exit codes
}
export async function validateFunc(param1: string, param2: string) {
{some code here}
return await tl.exec(`${validationToolRoot}\\<Exename>`, validationArgs);
}