diff --git a/src/UI/ScriptDocumentView.cc b/src/UI/ScriptDocumentView.cc
index 1f510c7c4f48db6686035121bd5229f4db3a34e1..a6d1732d6d6354fa443de4206b99dc87083acfe0 100644
--- a/src/UI/ScriptDocumentView.cc
+++ b/src/UI/ScriptDocumentView.cc
@@ -56,10 +56,20 @@ ScriptDocumentView::setUseFakeVimEditor(bool yes) noexcept
         connect(proxy, &EditorProxy::requestQuit, this, [this, mw]() noexcept -> void {
             mw->closeDocument(static_cast<AbstractDocumentView *>(this));
         });
-        connect(proxy, &EditorProxy::requestSave, this, [this]() { document->save(); });
+        connect(proxy, &EditorProxy::requestSave, this, [this]() noexcept -> void {
+            try {
+                document->save();
+            } catch (const std::runtime_error &e) {
+                logError() << "Failed to save current document: " << e.what();
+            }
+        });
         connect(proxy, &EditorProxy::requestSaveAndQuit, this, [this, mw]() noexcept -> void {
-            document->save();
-            mw->closeDocument(static_cast<AbstractDocumentView *>(this));
+            try {
+                document->save();
+                mw->closeDocument(static_cast<AbstractDocumentView *>(this));
+            } catch (const std::runtime_error &e) {
+                logError() << "Failed to save current document and close it: " << e.what();
+            }
         });
         initHandler(handler);
         clearUndoRedo(editor);