branch: externals/dicom
commit da915ac8db15001fa111109fb63eef159d87e132
Author: Daniel Mendler <[email protected]>
Commit: Daniel Mendler <[email protected]>

    Improve error handling
---
 dicom.el | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/dicom.el b/dicom.el
index 20e46956e5..1b3e945d1b 100644
--- a/dicom.el
+++ b/dicom.el
@@ -393,14 +393,18 @@ REUSE can be a buffer name to reuse."
     (unless (executable-find "convert")
       (push "convert" req))
     (when req
+      (kill-buffer)
       (error "DICOM: %s required to proceed" (string-join req ", ")))))
 
 (defun dicom--setup-locals (file)
   "Initialize buffer locals for FILE."
+  (unwind-protect
+      (setq-local dicom--data (dicom--read file))
+    (unless dicom--data
+      (kill-buffer)))
   (setq-local dicom--queue nil
               dicom--proc nil
               dicom--file file
-              dicom--data (dicom--read file)
               buffer-read-only t
               truncate-lines nil
               bookmark-make-record-function #'dicom--bookmark-record

Reply via email to