【发布时间】:2016-01-05 19:47:05
【问题描述】:
我有三个功能。 A --calling--> B --calling--> C. 没有任何闭包参数的简单函数,比如用于读取 plist、验证的函数...
假设 C 中出现错误。我在这里使用 Do/Try/Catch 来跨函数传递错误。
static func a(param: int)
{
do
{
try b()
}
catch
{
}
}
static func b(param: int)
{
//specific tasks in func b
c(1) //CAN I PASS THE ERROR TO FUNC a() without do/try/catch block?
}
static func c(param : int) throws
{
//Error created and throw’ed
}
顾名思义,我尝试使用 rethrow,但它需要一个带有 throw 的闭包! 有其他选择吗?
【问题讨论】:
标签: ios swift error-handling