Skip to content

Instantly share code, notes, and snippets.

@benjaminsnorris
Created May 9, 2016 21:51
Show Gist options
  • Save benjaminsnorris/8c6a05271a62f276fdf939c8f407ed2e to your computer and use it in GitHub Desktop.
Save benjaminsnorris/8c6a05271a62f276fdf939c8f407ed2e to your computer and use it in GitHub Desktop.
Add default text to all errors
extension ErrorType {
// MARK: - Internal functions
func describe() -> String {
if let error = self as? CustomStringConvertible {
return error.description
} else {
let error = self as NSError
return error.localizedDescription
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment