Rebol:执行多个文件(如库)时如何知道错误来自何处
Rebol 告诉错误和行,但没有说明在哪个源文件中,有没有办法从系统变量或其他(不仅仅是启动脚本)获取此信息?
Rebol tells the error and the line but it doesn't say in what source file, is there a way to get this info from a system variable or else (not only the starting script) ?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可以通过重载 DO 函数(假设所有脚本都使用 DO 而不是 LOAD 或 READ 加载到内存中)来跟踪错误发生之前执行的最后一个脚本(仅当系统/选项/安静被关闭时才需要)来实现这一点。库,因此您看不到每个加载脚本的 DO 本机日志行)。
在 REBOL 中,将运行时错误准确链接到源代码并不总是那么简单。一旦加载到内存中,就无法知道任何代码块的来源(文件或 url)。要么在加载阶段找到一种方法来捕获它,要么在控制台中使用详细的跟踪输出(使用 TRACE 功能或通常更好,并仔细放置 PRINT 和/或 PROBE)。
You might achieve that by overloading the DO function (given that all scripts are loaded in memory using DO and not LOAD or READ) to trace the last script executed before the error happens (only required if system/options/quiet is turned off by the library you're loading, so you don't see the DO native log line for each loaded script).
Accurately link runtime errors to your source code is not always simple in REBOL. Once loaded in memory, there's no way to tell the origin (file or url) for any code block. Either find a way to catch it before at loading stage, or use verbose tracing output in console (using TRACE function or often better, with carefully placed PRINTs and/or PROBEs).