img source: pexel.com Error is of vital importance. It can occur while communicating with , disk read or in a runtime situation. Let’s here it 🔉 network ‘A value used to report that an error condition occurred and normal functionality was skipped’ -Matt Gallagher, Cocoa with love Motivation Recently, I came across a by exhibiting some cool techniques about UIAlertController, explaining how to avoid the boilerplate code using extensions. snippet Ritesh Gupta swift Dirty Trick 💩 Failing gracefully, is what we want to achieve. Swift provides first-class support for at runtime. handling error Here’s the trick❗️ Real Life Usage 🌏 Let’s take an example of failing gracefully; So we have an app that tells your age based on your date of birth that you input. That’s lame 😑 We need to come up with some validation rules for DOB. We can cater all of them through our custom error; So Here’s the deal; basically the idea is to shout whenever you came across an error do { let yourAge = try age(from: yearOfBirth) } catch { error.alert(with: self) } Cool isn’t it? 🙃 Download Example App Author🙏 Feedback,👏 and stay tuned for more swifty tricks. Say hello on twitter . @khfarooq Thanks for reading! 🌟