Skip to content

Instantly share code, notes, and snippets.

@leptos-null
Created June 8, 2019 17:13
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save leptos-null/a7360b19215bb63da33e0c9d4ed22839 to your computer and use it in GitHub Desktop.
Save leptos-null/a7360b19215bb63da33e0c9d4ed22839 to your computer and use it in GitHub Desktop.
A generic error I use in Swift, typically for cases that are not intended to be dealt with in a manner other than being logged
struct GenericError: Error, CustomStringConvertible, CustomDebugStringConvertible, Equatable, Codable {
let description: String
let file: String
let function: String
let line: Int
init(message m: String, file f: String = #file, function n: String = #function, line l: Int = #line) {
description = m; file = f; function = n; line = l
}
var debugDescription: String {
/* this looks like: file.swift:1 function(parameter:) "description" */
return "\(file):\(line) \(function) \"\(description)\""
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment