Skip to content

Instantly share code, notes, and snippets.

View DzmitrySmaliakou's full-sized avatar

Dzmitry Smaliakou DzmitrySmaliakou

View GitHub Profile
// Swift's untyped errors are a goddam PiTA. Here's the pattern I use to try to work around this.
// The goal is basically to try to guarantee that every throwing function in the app throws an
// ApplicationError instead of some unknown error type. We can't actually enforce this statically
// But by following this convention we can simplify error handling
enum ApplicationError: Error, CustomStringConvertible {
// These are application-specific errors that may need special treatment
case specificError1
case specificError2(SomeType)