简体   繁体   English

有没有办法抑制 Julia REPL 中伴随错误的堆栈跟踪?

[英]Is there a way to suppress the stacktrace that accompanies an error in the Julia REPL?

Is there a way to suppress the stacktrace that accompanies an error in the Julia REPL (VS Code specific methods acceptable)?有没有办法抑制 Julia REPL 中伴随错误的堆栈跟踪(可接受 VS 代码特定方法)? It fills my screen with a lot of output that is not useful for me to fix the error, and I regularly must scroll up through it to find the useful, single, first line of error description, and find this inefficient and messy.它用很多 output 填满我的屏幕,这对我修复错误没有用处,我必须经常向上滚动以找到有用的、单一的、第一行错误描述,并发现这效率低下且混乱。

Maybe not quite what you wanted, but it's close:也许不是你想要的,但它很接近:

julia> # Sequence of dummy functions to generate long stack trace
       f() = g()
       g() = h()
       h() = k()
       k() = error("Hello world")
k (generic function with 2 methods)

julia> # Default: long stacktrace
       f()
ERROR: Hello world
Stacktrace:
 [1] error(::String) at ./error.jl:33
 [2] k() at ./REPL[72]:5
 [3] h() at ./REPL[72]:4
 [4] g() at ./REPL[72]:3
 [5] f() at ./REPL[72]:2
 [6] top-level scope at REPL[73]:2

julia> # try/catch to eliminate stacktrace
       try
           f()
       catch e
           printstyled(stderr,"ERROR: ", bold=true, color=:red)
           printstyled(stderr,sprint(showerror,e), color=:light_red)
           println(stderr)
       end
ERROR: Hello world

VS Code specific solution VS Code 具体解决方案

Installing the "Julia Insiders" extension instead of the regular "Julia" extension solves this issue, as explained here .安装“Julia Insiders”扩展而不是常规的“Julia”扩展可以解决这个问题, 如here所述

I can see the fix is merged into the main branch but for some reason it hasn't made its way into the regular extension.我可以看到该修复程序已合并到主分支中,但由于某种原因,它还没有进入常规扩展程序。

暂无
暂无

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

相关问题 启动 Julia REPL 时奇怪的源命令 - Strange source command when start Julia REPL JSHint 抑制可选链接的错误 - JSHint suppress error for optional chaining 当我在 VS Code 中编程 Julia 时,为什么快捷方式“Ctrl + Enter”不会将我的当前行发送到 REPL? - Why the shortcut "Ctrl + Enter" doesn't send my current line to REPL when I program Julia in VS Code? 是否可以抑制vscode中类似函数的导入的语法错误 - Is it possible to suppress syntax error for function-like imports in vscode 在 vscode 扩展中有一种方法可以通过 vscode.commands.executeCommand(...) 以编程方式调用“repl.action.copyall” - In a vscode extension is there a way to programatically Invoke "repl.action.copyall" through vscode.commands.executeCommand(...) 有没有办法显示 Julia 中的每一行代码,当它没有被“;”抑制时,就像在 MATLAB 中一样? - Is there a way to display every line of code in Julia when it is not suppressed with ";" , like in MATLAB? 错误:导入笔记本需要安装 Jupyter nbconvert。 朱莉娅 - Error: Importing notebooks requires Jupyter nbconvert to be installed. Julia 在 VsCode Ubuntu / Julia Ubuntu Store 版本中捕捉 Julia 二进制设置错误 - Snap Julia binary setup error in VsCode Ubuntu / Julia Ubuntu Store Version VSCode pipenv运行REPL程序收到环境激活,导致初始语法错误 - VSCode pipenv run REPL program receives environment activation causing initial syntax error cabal repl 给出错误“找不到模块”,但它被列为依赖项并且 cabal 构建工作 - cabal repl gives error "cannot find module" but it is listed as dependency and cabal build works
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM