Pick the fix
In Swift 6 you want do { try parse() } catch { ... } where error is statically a ParseError. Which declaration?
Hint 1 of 1
Which feature arrived in Swift 6?
Choose an answer, then open Show answer below to check it.
Show answer
Answer: A func parse() throws(ParseError) -> Config
Correct. Typed throws makes the catch variable a ParseError.
Why not the others?
- B
func parse() -> Result<Config, ParseError>. That is typed too, but callers switch on the result instead of using do/catch. - C
func parse() throws -> Configand cast in catch. The error isany Error; you'd need a cast. - D
func parse() rethrows -> Config. rethrows only applies to functions that take throwing closures.