visual-studio-code - 有没有办法抑制 Julia REPL 中伴随错误的堆栈跟踪?
问题描述
有没有办法抑制 Julia REPL 中伴随错误的堆栈跟踪(可接受 VS Code 特定方法)?它在我的屏幕上填满了很多对我修复错误没有用处的输出,我必须经常向上滚动以找到有用的、单一的、第一行错误描述,并发现这效率低下且混乱。
解决方案
也许不是你想要的,但它很接近:
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
推荐阅读
- for-loop - Verilog For 循环
- python - 如何使用 beautifulsoup 获取 A-Tag 的属性值 - 基于条件:标题字符串包含关键字
- python - Numpy 中的填充功能
- python - Python看门狗 - 在复制目录之前检查复制是否完成
- mysql - 是否可以在存储过程中为参数数据类型传入 auto_increment?
- r - 不能使用 grepl 和 mutate 函数
- json - 使用 Google Apps 脚本从 JSON 对象创建 Google Sheet
- postgresql - heimir-sverrisson 为 postgres 构建 jdbc2_fdw 时出现几个构建错误
- angular - Primeng 编辑器添加撤消和重做按钮
- postgresql - 如何抑制来自控制台的警告