Skip to content

Instantly share code, notes, and snippets.

@vialyx
Created February 19, 2018 13:40
Show Gist options
  • Save vialyx/b081765b0a126c4d1e1375c932865352 to your computer and use it in GitHub Desktop.
Save vialyx/b081765b0a126c4d1e1375c932865352 to your computer and use it in GitHub Desktop.
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