Swift 2.0 Error Handling

Swift is a safe language and even though many will swear by Objective-C’s long standing “good practices”, there are some really cool features that came out with Swift 2.0. In particular, the new way to handle errors, or the ability to define your own is insanely cool. This feature is probably one of my favorites… Although there are probably articles on the internet covering this topic, here is another one just in case you wanted to read up on it some more.

I have absolutely no intention of mentioning Objective-C’s @try / @catch as I personally don’t believe they are related outside of the actual syntax being somewhat similar. Unrecoverable errors are useless if you ask me… what good is it to know you have an “unrecoverable error”?

Continue reading “Swift 2.0 Error Handling”

Swift 2.0 Error Handling

Swift At Work…

I’ve been going through my projects for the past few weeks updating them to Swift 2.0. In particular, I released MBGithubOAuthClient a few years back that I needed to rewrite in Swift. To show how awesome and safe Swift is, here are two functions side-by-side:

This is the same function is Swift:

As you can see, there is no reason to type check and write throwException function anymore. Awesome.

Swift At Work…