Created
November 23, 2018 13:40
-
-
Save vasilevkin/b1e2e7c17220c60f1b32daf5b8ded717 to your computer and use it in GitHub Desktop.
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
enum ErrorsWhenCasting : Error { | |
case wrongType | |
} | |
private static func value<T>(valueRaw: LoginResponse) throws -> T { | |
guard let castedValue = valueRaw as? T else { | |
throw ErrorsWhenCasting.wrongType | |
} | |
return castedValue | |
} | |
do { | |
let valueNew = value(valueRaw: response) | |
} catch ErrorsWhenCasting.wrongType { | |
print("Unable to cast, catched wrong type error") | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment