Bitburner

Bitburner

查看统计:
Cthary 2022 年 3 月 6 日 下午 2:46
Nuke ignores try-catch
Heyho,
i currently try to auto nuke servers.
The Problem is this:
try {
ns.nuke(server)
ns.print("SERVER="+server+" NUKED")
} catch { }

I get a "Script crashed with runtime error" here, "nuke: Not enough ports opened to use NUKE.exe virus.".

How can that be ? i mean, the error is correct but should be catched and ignored.

I solved the problem by creating checks beforehand... but still... why didn't it got catched ?
最后由 Cthary 编辑于; 2022 年 3 月 6 日 下午 2:56
< >
正在显示第 1 - 1 条,共 1 条留言
Ekis93 2022 年 3 月 7 日 下午 12:59 
You need to define the catch error. This for instance will catch any error event.

/** @param {NS} ns **/
export async function main(ns)
{
try { ns.nuke(host); }
catch { ErrorEvent; }
}

To elaborate; an empty catch should work since it's checking for any and all errors, but I've also run into situations where I get a runtime error while using an empty catch.
最后由 Ekis93 编辑于; 2022 年 3 月 7 日 下午 1:17
< >
正在显示第 1 - 1 条,共 1 条留言
每页显示数: 1530 50

发帖日期: 2022 年 3 月 6 日 下午 2:46
回复数: 1