How to edit swift error breakpoint?

*爱你&永不变心* 提交于 2019-12-10 10:07:21

问题


I want to set Swift error breakpoint to handle Swift Error of ErrorType in swift. But i am not getting What to set as Type value in BreakPoint ?


回答1:


If you just create a Swift error breakpoint, it breaks on anything that conforms to ErrorType.

If you put something in Type, it'll only break when that type is thrown.

In the following:

enum MyError: ErrorType
{
    case AnError
}

enum MyOtherError: ErrorType
{
    case AnotherError
}

public func throwAnError()
{
    do
    {
        throw MyOtherError.AnotherError
    }
    catch
    {
        print("Caught 1")
    }

    do
    {
        throw MyError.AnError
    }
    catch
    {
        print("Caught 2")
    }
}

A break on Swift error will cause the debugger to stop on both throw lines. If you put MyError in the type field, the debugger will only stop on the second throw line.



来源:https://stackoverflow.com/questions/34436629/how-to-edit-swift-error-breakpoint

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!