From 1ec0bef2bdc8c1b937eef71f93d35e98f0f2f688 Mon Sep 17 00:00:00 2001
From: Arun Isaac
Date: Wed, 20 Sep 2023 10:35:08 +0100
Subject: scripts: Ignore quit exceptions when requesting the user report bugs.

* scripts/ccwl: Import (ice-9 exceptions).
(main): Do not print backtrace or request the user to report a bug for
quit exceptions.
---
 scripts/ccwl | 18 ++++++++++++------
 1 file changed, 12 insertions(+), 6 deletions(-)

diff --git a/scripts/ccwl b/scripts/ccwl
index e299413..57078dd 100755
--- a/scripts/ccwl
+++ b/scripts/ccwl
@@ -30,6 +30,7 @@ exec guile --no-auto-compile -e main -s "$0" "$@"
              (srfi srfi-28)
              (srfi srfi-37)
              (ice-9 match)
+             (ice-9 exceptions)
              (ccwl ccwl)
              (ccwl conditions)
              (ccwl cwl)
@@ -50,16 +51,21 @@ exec guile --no-auto-compile -e main -s "$0" "$@"
 (define (main args)
   (with-exception-handler
       (lambda (condition)
-        (display-backtrace (make-stack #t) (current-error-port))
-        (newline (current-error-port))
-        (write condition (current-error-port))
-        (newline (current-error-port))
-        (display "
+        ;; Catch uncaught exceptions, print their backtrace and
+        ;; request the user report an issue. Pass quit exceptions
+        ;; through since those may be raised by exceptions that have
+        ;; been handled.
+        (unless (quit-exception? condition)
+          (display-backtrace (make-stack #t) (current-error-port))
+          (newline (current-error-port))
+          (write condition (current-error-port))
+          (newline (current-error-port))
+          (display "
 You have discovered a bug!
 Please report this to https://github.com/arunisaac/ccwl/issues
 Thank you!
 "
-                 (current-error-port))
+                   (current-error-port)))
         (exit #f))
     (lambda ()
       (match args
-- 
cgit v1.2.3