简体   繁体   English

如何捕获我在 ElectroNeek Studio Pro 中使用 JavaScript 块抛出的错误消息

[英]How can I capture an error message I throw using the JavaScript block in ElectroNeek Studio Pro

When I use the JavaScript block I want to be able to capture an error message I throw using the red error exit bubble on the JavaScript Activity.当我使用 JavaScript 块时,我希望能够捕获我在 JavaScript 活动上使用红色错误退出气泡抛出的错误消息。 Right now whatever string I put in the throw always comes back as “error”.现在,无论我在 throw 中放入什么字符串,都会返回为“error”。 I do not find it desireable to save another variable in the block as an error message outside of the throw.我不认为将块中的另一个变量保存为抛出之外的错误消息是可取的。

enter image description here在此处输入图像描述

I would expect the console log to have the custom error message and not error.我希望控制台日志包含自定义错误消息而不是错误。

Thanks for the question, I would recommend you try using: throw Error("Some custom error message") .感谢您提出问题,我建议您尝试使用: throw Error("Some custom error message") This should work.这应该工作。 You can also follow our forum for more information on this: Here您也可以关注我们的论坛以获取更多相关信息:此处

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

相关问题 JScript:未加载图像时,如何抛出错误消息? - JScript: How can I throw an error message when image is not loaded? 如何在 javascript 中的 if (message == “...”) 之后捕获文本 - How can I capture text after a if (message == “…”) in javascript 如何捕获 Firefox 的套接字连接错误消息? - How can I capture Firefox's socket connection error message? 在 Javascript 中,如果缺少环境变量,如何抛出错误? - In Javascript, how can I throw an error if an environmental variable is missing? 在 Javascript 中,如何抛出将对象打印到控制台的错误? - In Javascript, how can I throw an error that prints an object to the console? 如何使用JavaScript捕获内部LAN IP地址 - How can I capture the internal LAN IP address using javascript 如何创建 Error 的子类型来抛出它? - How can I create a subtype of Error to throw it? 如何解决“抛出新错误('无法解析 privateKey:' + privKeyInfo.message);” 在 Windows - How can i resolve “throw new Error('Cannot parse privateKey: ' + privKeyInfo.message);” in Windows JavaScript 错误处理:我可以在三元运算符中抛出错误吗? - JavaScript error handling: can I throw an error inside a ternary operator? 如何使用 JavaScript 截取网页截图? - How can I capture webpage screenshots with JavaScript?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM