Skip to content

Instantly share code, notes, and snippets.

@macbaszii
Last active September 21, 2015 04:47
Show Gist options
  • Select an option

  • Save macbaszii/858321613db8c9583b74 to your computer and use it in GitHub Desktop.

Select an option

Save macbaszii/858321613db8c9583b74 to your computer and use it in GitHub Desktop.
do {
try canPurchaseItem(specificItem, forUser: specificUser)
} catch PurchaseError.OutOfStockItem {
print("The Item is out of stock")
} catch PurchaseError.InsufficientFunds {
print("Your money is insufficient to buy this item")
}
// In case that you make sure the function always doesn't throw the error
try! canPurchaseItem(specificItem, forUser: specificUser)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment