diff --git a/jupyter_server/services/contents/manager.py b/jupyter_server/services/contents/manager.py index c91c4493cf..8d3d25ccb2 100644 --- a/jupyter_server/services/contents/manager.py +++ b/jupyter_server/services/contents/manager.py @@ -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)