本文简要介绍ruby语言中 StandardError类
的用法。
最标准的错误类型是 StandardError
的子类。没有明确的 Exception
类的救援子句将救援所有StandardErrors(并且只有那些)。
def foo
raise "Oups"
end
foo rescue "Hello" #=> "Hello"
另一方面:
require 'does/not/exist' rescue "Hi"
raises the exception:
LoadError: no such file to load -- does/not/exist
相关用法
- Ruby Stat.stat <=>用法及代码示例
- Ruby Stat.world_writable?用法及代码示例
- Ruby Stat.birthtime用法及代码示例
- Ruby Status.to_s用法及代码示例
- Ruby Stat.ino用法及代码示例
- Ruby Stat.readable_real?用法及代码示例
- Ruby Stat.blockdev?用法及代码示例
- Ruby Stat.grpowned?用法及代码示例
- Ruby Stat.mode用法及代码示例
- Ruby Stat.setuid?用法及代码示例
- Ruby Stat.ftype用法及代码示例
- Ruby Stat.blocks用法及代码示例
- Ruby Stat.ctime用法及代码示例
- Ruby Stat.rdev_major用法及代码示例
- Ruby Stat.gid用法及代码示例
- Ruby Stat.world_readable?用法及代码示例
- Ruby Stat.size用法及代码示例
- Ruby Stat.atime用法及代码示例
- Ruby Stat.dev_major用法及代码示例
- Ruby Stat.writable_real?用法及代码示例
- Ruby Status.exitstatus用法及代码示例
- Ruby Stat.dev_minor用法及代码示例
- Ruby Stat.owned?用法及代码示例
- Ruby Stat.file?用法及代码示例
- Ruby Status类用法及代码示例
注:本文由纯净天空筛选整理自ruby-lang.org大神的英文原创作品 StandardError类。非经特殊声明,原始代码版权归原作者所有,本译文未经允许或授权,请勿转载或复制。