方法抛出异常
异常处理
捕获所有异常
捕获特定异常
抛出异常
重新抛出异常
定义异常类型
确保执行(finally)
未发生异常时
方法抛出异常
# 任何方法都可能抛出错误
def
method_with_exception
()
raise
"test exception"
end
method_with_exception
()
# <-Error
语言
Python
C++
Java
C#
JavaScript
Rust
Golang
Delphi
PHP
Swift
Kotlin
TypeScript
Clojure
Objective-C