Catch exceptions during API call.

Fix bugs in swit_app_key