Skip to content

Commit

Permalink
Merge pull request #456 from minrk/allow-pre-save-raise
Browse files Browse the repository at this point in the history
allow pre_save_hook to cancel save with HTTPError
  • Loading branch information
blink1073 authored Mar 24, 2021
2 parents a6a5d10 + 40f653d commit c3303cd
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions jupyter_server/services/contents/manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,13 @@ def run_pre_save_hook(self, model, path, **kwargs):
try:
self.log.debug("Running pre-save hook on %s", path)
self.pre_save_hook(model=model, path=path, contents_manager=self, **kwargs)
except HTTPError:
# allow custom HTTPErrors to raise,
# rejecting the save with a message.
raise
except Exception:
# unhandled errors don't prevent saving,
# which could cause frustrating data loss
self.log.error("Pre-save hook failed on %s", path, exc_info=True)

checkpoints_class = Type(Checkpoints, config=True)
Expand Down

0 comments on commit c3303cd

Please sign in to comment.