Created
February 19, 2018 13:40
-
-
Save vialyx/b081765b0a126c4d1e1375c932865352 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
enum InstanceError: Error { | |
case parentNotFound | |
case notFullJSON | |
} | |
func createInstance(data: [String: Any]) throws { | |
guard let id = data["id"] as? String else { | |
throw InstanceError.notFullJSON | |
} | |
} | |
do { | |
try createInstance(data: [:]) | |
} catch InstanceError.parentNotFound { | |
print("Be sure that you have parent instance") | |
} catch InstanceError.notFullJSON { | |
print("The initial JSON data isn't full") | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment