Xcode-beta (7A120f): Do-catch is cumbersome

Originator:owensd
Number:rdar://21406512 Date Originated:16-Jun-2015 11:58 AM
Status:Open Resolved:
Product:Developer Tools Product Version:Xcode-beta (7A120f)
Classification:Enhancement Reproducible:Always
 
The entire do-try-catch pattern is really cumbersome. It promotes error handling code that is far away from the code and generic error handling. 

It would be much nicer to write error handling code like this:

try f() catch { /* error handling code */ }

Merging this with guard is natural as well:

guard let r = f() catch { /* scope exiting error handling code */ }

A further write up is here: http://owensd.io/2015/06/16/do-catch.html

Comments


Please note: Reports posted here will not necessarily be seen by Apple. All problems should be submitted at bugreport.apple.com before they are posted here. Please only post information for Radars that you have filed yourself, and please do not include Apple confidential information in your posts. Thank you!