Created
November 30, 2017 10:25
-
-
Save takasek/dbeab7b041f5d5630ac2a0e4754a1836 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
import Foundation | |
struct Default: LocalizedError { | |
} | |
struct E: LocalizedError { | |
let errorDescription: String? = "e" | |
} | |
struct F: LocalizedError { | |
let failureReason: String? = "f" | |
} | |
struct R: LocalizedError { | |
let recoverySuggestion: String? = "r" | |
} | |
struct H: LocalizedError { | |
let helpAnchor: String? = "h" | |
} | |
struct EFRH: LocalizedError { | |
let errorDescription: String? = "e" | |
let failureReason: String? = "f" | |
let recoverySuggestion: String? = "r" | |
let helpAnchor: String? = "h" | |
} | |
let errors: [LocalizedError] = [ | |
Default(), E(), F(), R(), H(), EFRH() | |
] | |
errors.forEach { | |
print( | |
"[\(type(of: $0))]", | |
"\n ๐ \($0.localizedDescription)", | |
"\n ๐", | |
$0.errorDescription ?? "_", | |
$0.failureReason ?? "_", | |
$0.recoverySuggestion ?? "_", | |
$0.helpAnchor ?? "_" | |
) | |
} | |
/* | |
[Default] | |
๐ The operation couldnโt be completed. (__lldb_expr_260.Default error 1.) | |
๐ _ _ _ _ | |
[E] | |
๐ e | |
๐ e _ _ _ | |
[F] | |
๐ The operation couldnโt be completed. f | |
๐ _ f _ _ | |
[R] | |
๐ The operation couldnโt be completed. (__lldb_expr_260.R error 1.) | |
๐ _ _ r _ | |
[H] | |
๐ The operation couldnโt be completed. (__lldb_expr_260.H error 1.) | |
๐ _ _ _ h | |
[EFRH] | |
๐ e | |
๐ e f r h | |
*/ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment