Skip to content

Commit

Permalink
Fix error message handling in except blocks
Browse files Browse the repository at this point in the history
  • Loading branch information
tnakazato committed Jan 20, 2025
1 parent 520d236 commit 1995fe6
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions casaconfig/private/data_update.py
Original file line number Diff line number Diff line change
Expand Up @@ -330,7 +330,7 @@ def data_update(path=None, version=None, force=False, logger=None, auto_update_r

except BadLock as exc:
# the path is known to exist so this means that the lock file was not empty and it's not locked
msgs = str(exc)
msgs = [str(exc)]
msgs.append('data_update: the lock file at %s is not empty.' % path)
msgs.append('A previous attempt to update path may have failed or exited prematurely.')
msgs.append('Remove the lock file and set force to True with the desired version (default to most recent).')
Expand All @@ -341,7 +341,7 @@ def data_update(path=None, version=None, force=False, logger=None, auto_update_r

except BadReadme as exc:
# something is wrong in the readme after an update was triggered, this shouldn't happen, print more context reraise this
msgs = str(exc)
msgs = [str(exc)]
msgs.append('This should not happen unless multiple sessions are trying to update data at the same time and one experienced problems or was done out of sequence')
msgs.append('Check for other updates in progress or choose a different path or clear out this path and try again using pull_data or update_all')
print_log_messages(msgs, logger, True)
Expand Down
4 changes: 2 additions & 2 deletions casaconfig/private/pull_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -283,7 +283,7 @@ def pull_data(path=None, version=None, force=False, logger=None, verbose=None):

except BadLock as exc:
# the path is known to exist so this means that the lock file was not empty and it's not locked
msgs = str(exc)
msgs = [str(exc)]
msgs.append('The lock file at %s is not empty.' % path)
msgs.append('A previous attempt to update path may have failed or exited prematurely.')
msgs.append('It may be best to completely repopulated path using pull_data and measures_update.')
Expand All @@ -292,7 +292,7 @@ def pull_data(path=None, version=None, force=False, logger=None, verbose=None):
raise
except BadReadme as exc:
# something is wrong in the readme after an update was triggered and locked, this shouldn't happen, print more context and reraise this
msgs = str(exc)
msgs = [str(exc)]
msgs.append('This should not happen unless multiple sessions are trying to update data at the same time and one experienced problems or was done out of sequence')
msgs.append('Check for other updates in progress or choose a different path or clear out this path and try again')
print_log_messages(msgs, logger, True)
Expand Down

0 comments on commit 1995fe6

Please sign in to comment.