Skip to content

Commit

Permalink
Exit with nice error message failing to get repositories
Browse files Browse the repository at this point in the history
If we throw an OfflineImapError in case of the Repository()
initialization, we display the nice error message and exit rather
than bomb out with a traceback. Misconfiguring a repository name in
the configuration file is now nicely pointed out to the user.

Signed-off-by: Sebastian Spaeth <[email protected]>
  • Loading branch information
spaetz committed Aug 31, 2012
1 parent 103524c commit 04ffae2
Showing 1 changed file with 13 additions and 7 deletions.
20 changes: 13 additions & 7 deletions offlineimap/accounts.py
Original file line number Diff line number Diff line change
Expand Up @@ -217,13 +217,19 @@ def unlock(self):

def syncrunner(self):
self.ui.registerthread(self)
accountmetadata = self.getaccountmeta()
if not os.path.exists(accountmetadata):
os.mkdir(accountmetadata, 0o700)

self.remoterepos = Repository(self, 'remote')
self.localrepos = Repository(self, 'local')
self.statusrepos = Repository(self, 'status')
try:
accountmetadata = self.getaccountmeta()
if not os.path.exists(accountmetadata):
os.mkdir(accountmetadata, 0o700)

self.remoterepos = Repository(self, 'remote')
self.localrepos = Repository(self, 'local')
self.statusrepos = Repository(self, 'status')
except OfflineImapError as e:
self.ui.error(e, exc_info()[2])
if e.severity >= OfflineImapError.ERROR.CRITICAL:
raise
return

# Loop account sync if needed (bail out after 3 failures)
looping = 3
Expand Down

0 comments on commit 04ffae2

Please sign in to comment.