简体   繁体   English

console.error 是否在触发时停止代码执行?

[英]Does console.error stops the code execution when fired?

I am writing a program which loads a file and run some functions on it.我正在编写一个加载文件并在其上运行一些函数的程序。 Multiple files can be loaded.可以加载多个文件。

If there's an error loading the file, like a misspelling of the name, I log a console.error .如果加载文件时出现错误,例如名称拼写错误,我会记录一个console.error But I don't want to stop the execution.但我不想停止执行。

Does console.error stops the execution? console.error是否停止执行? Does throw new error can be an alternative? throw new error是否可以替代? Or should I use console.warn ?或者我应该使用console.warn吗?

Does console.error stops the execution? console.error 是否停止执行?

No

Does throw new error can be an alternative?抛出新错误是否可以替代?

Yes, as follow: throw new Error("Message");是的,如下: throw new Error("Message");

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM