How get the list of errors thrown by a function?

前端 未结 3 1523
太阳男子
太阳男子 2020-12-03 21:34

With Swift now some functions are marked with throws, and this force the developers to call the function inside a do - try catch block. But how the

3条回答
  •  被撕碎了的回忆
    2020-12-03 21:57

    You write a pattern after catch to indicate what errors that clause can handle.

    do {
        try expression
        statements
    } catch pattern 1 {
        statements
    } catch pattern 2 where condition {
        statements
    }
    

    See section Handling Errors Using Do-Catch of Swift Programming Language

提交回复
热议问题