Created
June 8, 2019 17:13
-
-
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
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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