gpt4 book ai didi

javascript - 识别 Javascript 中的函数名称或属性

转载 作者:行者123 更新时间:2023-12-05 03:52:36 26 4
gpt4 key购买 nike

<分区>

我正在使用一个 npm 模块,它在错误时抛出一个空函数,即 UnauthorizedException。我希望能够识别抛出的函数,以便我可以相应地处理它

function UnauthorizedException() {

}

const f = () => {
throw (new UnauthorizedException());
};

try {
f();
} catch (err) {
// How to identity a function name/property/etc so I can handle the error accordingly
console.log(err);
console.log(typeof (err));
}

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com