# HG changeset patch # User Matti Hamalainen # Date 1467717357 -10800 # Node ID ac949d2b268a1dee715fe6fbf89771d6ccf47a81 # Parent 9eadb97a2e98d0178725d1aca8f84a35c744cd75 Add some error handling. diff -r 9eadb97a2e98 -r ac949d2b268a multimerge.py --- a/multimerge.py Tue Jul 05 14:11:26 2016 +0300 +++ b/multimerge.py Tue Jul 05 14:15:57 2016 +0300 @@ -77,10 +77,18 @@ ## Function for handling Google API credentials def gcm_get_credentials(mcfg): - store = oauth2client.file.Storage(mcfg.credential_file) + try: + store = oauth2client.file.Storage(mcfg.credential_file) + except Exception as e: + gcm_fatal("Failed to read credential file:\n{0}\n\nERROR: {1}\n".format(mcfg.credential_file, str(e))) + credentials = store.get() if not credentials or credentials.invalid: - flow = client.flow_from_clientsecrets(mcfg.secret_file, mcfg.scope) + try: + flow = client.flow_from_clientsecrets(mcfg.secret_file, mcfg.scope) + except Exception as e: + gcm_fatal("Failed to fetch client secret:\n{0}\n\nERROR: {1}\n".format(mcfg.secret_file, str(e))) + flow.user_agent = mcfg.app_name credentials = tools.run_flow(flow, store, mcfg) if not credentials or credentials.invalid: