Skip to content

Instantly share code, notes, and snippets.

@SecurityForUs
Created September 26, 2012 20:03
Show Gist options
  • Save SecurityForUs/3790238 to your computer and use it in GitHub Desktop.
Save SecurityForUs/3790238 to your computer and use it in GitHub Desktop.
example of exception in python for balanced
def addClient(self, email, cardUri):
try:
client = balanced.Marketplace.my_marketplace.create_buyer(email, cardUri)
return True
except balanced.exc.HttpError as e:
if e.category_code == "duplicate-email-address":
buyer = balanced.Account.query.filter(email_address=email)
print buyer
buyer = buyer[0]
buyer.add_card(cardUri)
else:
print e
return False
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment