强制红宝石在异常时隐藏回溯

编程入门 行业动态 更新时间:2024-10-27 19:16:08
本文介绍了强制红宝石在异常时隐藏回溯的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我用Rakefile做一些常规任务,例如编译,链接等.

I do some usual tasks with Rakefile, such as compilation, linking, etc.

当编译失败时,ruby会显示发生任务错误的完整回溯,但对我来说真的没用,甚至更多:此回溯会隐藏编译错误.

When compilation fails ruby shows full backtrace in which task error happen, but it's really useless for me, even more: this backtrace hides compilation errors.

$ rake mkdir -p build llvm-as source/repl.ll -o build/repl.bc llvm-as: source/repl.ll:6:22: error: expected value token call i32 @fputc(i8 'x', i32 0) ^ rake aborted! Command failed with status (1): [llvm-as source/repl.ll -o build/repl.bc...] /usr/local/lib/ruby/1.9.1/rake.rb:993:in `block in sh' /usr/local/lib/ruby/1.9.1/rake.rb:1008:in `call' /usr/local/lib/ruby/1.9.1/rake.rb:1008:in `sh' /usr/local/lib/ruby/1.9.1/rake.rb:1092:in `sh' ...

如何在耙中止!"之后隐藏所有内容! ?

How to hide all after "rake aborted!" ?

推荐答案

似乎您在rake任务中使用"sh"命令来启动编译器.在这种情况下,您应该捕获RuntimeError,以获取此错误.像这样:

It seems that you are using the "sh" command in the rake task to start the compiler. In that case you should catch a RuntimeError, in order to get this error. Something like this:

task "foo" do begin sh "bar" rescue RuntimeError => e puts e.message exit(1) end end

更多推荐

强制红宝石在异常时隐藏回溯

本文发布于:2023-10-26 20:41:12,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1531289.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:红宝石   异常

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!