在java中,如果一个方法抛出错误,则调用它的方法可以将其传递给下一个方法.
public void foo() throws Exception {
throw new Exception();
}
public void bar() throws Exception {
foo();
}
public static void main(String args[]) {
try {
bar();
}
catch(Exception e) {
System.out.println("Error");
}
}
Run Code Online (Sandbox Code Playgroud)
我正在写一个快速的应用程序,并希望做同样的事情.这可能吗?如果不可能有什么其他可能的解决方案?我调用此调用的原始函数具有此结构.
func convert(name: String) throws -> String {
}
Run Code Online (Sandbox Code Playgroud)