Rebol:执行多个文件(如库)时如何知道错误来自何处

发布于 2024-08-14 06:49:55 字数 62 浏览 2 评论 0原文

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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

腻橙味 2024-08-21 06:49:55

您可以通过重载 DO 函数(假设所有脚本都使用 DO 而不是 LOAD 或 READ 加载到内存中)来跟踪错误发生之前执行的最后一个脚本(仅当系统/选项/安静被关闭时才需要)来实现这一点。库,因此您看不到每个加载脚本的 DO 本机日志行)。

do: func [value /args arg /next][
    if file? value [print ["DOing script:" value]]
    case [
        args [system/words/do/args value arg]
        next [system/words/do/next value]
        ;-- args + next is possible, but never used in practice
    ]
]

在 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).

do: func [value /args arg /next][
    if file? value [print ["DOing script:" value]]
    case [
        args [system/words/do/args value arg]
        next [system/words/do/next value]
        ;-- args + next is possible, but never used in practice
    ]
]

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).

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文