Avatar
@swift-5.9.2 struct MyError: Error {} func canThrow() throws { throw MyError() }; protocol SomeRandomProtocol {} do { try canThrow() } catch let error where error is SomeRandomProtocol, { print("SomeRandomProtocol: \(error)") } catch { print("Default: \(error)") } (edited)