Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/cocoa/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ruby Errno::SystemCaller未捕获到ETIMEDOUT错误_Ruby_Exception Handling - Fatal编程技术网

Ruby Errno::SystemCaller未捕获到ETIMEDOUT错误

Ruby Errno::SystemCaller未捕获到ETIMEDOUT错误,ruby,exception-handling,Ruby,Exception Handling,我在Ruby 1.8.7中有一段代码 rescue SystemCallError 但该程序偶尔会以Errno::ETIMEDOUT退出。SytemCallerError不应该捕获所有Errno错误吗 编辑:代码是 rescue SystemCallError, StandardError 谢谢当然应该如此!您确定rescue在抛出的错误路径中吗 >> Errno::ETIMEDOUT.superclass SystemCallError >> Errno::E

我在Ruby 1.8.7中有一段代码

 rescue SystemCallError 
但该程序偶尔会以
Errno::ETIMEDOUT
退出。SytemCallerError不应该捕获所有Errno错误吗

编辑:代码是

 rescue SystemCallError, StandardError

谢谢

当然应该如此!您确定
rescue
在抛出的错误路径中吗

>> Errno::ETIMEDOUT.superclass
SystemCallError
>> Errno::ETIMEDOUT.new.is_a? SystemCallError
true
此外:

>开始
?>提出错误号::ETIMEDOUT,“请失败”
>>救援系统调用程序错误,标准错误
>>放入“捕获{$!.inspect}”
>>结束
抓住#

非常确定,不过我会仔细检查堆栈跟踪。如果它被重新提升会有关系吗?我认为重新提升不会导致问题(除非它被另一个异常类包装)如果在封面下有一些hokey的特殊外壳打破了这一点,那也就不足为奇了:-/我似乎记得POSIX异常类是奇怪地生成的。测试可能是完全删除类的白名单,看看通过
$可以得到什么
>> begin
?>   raise Errno::ETIMEDOUT, "Fail, please"
>> rescue SystemCallError, StandardError
>>   puts "Caught #{$!.inspect}"
>> end
Caught #<Errno::ETIMEDOUT: Operation timed out - Fail, please>