@@ -16,6 +16,10 @@ import Prelude.Kore
1616
1717import qualified Codec.Archive.Tar as Tar
1818import qualified Codec.Compression.GZip as GZip
19+ import Control.Exception
20+ ( AsyncException (UserInterrupt )
21+ , fromException
22+ )
1923import Control.Monad.Catch
2024 ( ExitCase (.. )
2125 , displayException
@@ -79,7 +83,7 @@ writeBugReportArchive base tar = do
7983{- | Run the inner action with a temporary directory holding the bug report.
8084
8185The bug report will be saved as an archive if that was requested by the user, or
82- if there is an error in the inner action.
86+ if there is an error in the inner action other than 'UserInterrupt' .
8387
8488 -}
8589withBugReport
@@ -104,10 +108,13 @@ withBugReport exeName bugReport act =
104108 releaseTempDirectory tmpDir exitCase = do
105109 case exitCase of
106110 ExitCaseSuccess _ -> optionalWriteBugReport tmpDir
107- ExitCaseException someException -> do
108- let message = displayException someException
109- writeFile (tmpDir </> " error" <.> " log" ) message
110- alwaysWriteBugReport tmpDir
111+ ExitCaseException someException
112+ | Just UserInterrupt == fromException someException ->
113+ optionalWriteBugReport tmpDir
114+ | otherwise -> do
115+ let message = displayException someException
116+ writeFile (tmpDir </> " error" <.> " log" ) message
117+ alwaysWriteBugReport tmpDir
111118 ExitCaseAbort -> alwaysWriteBugReport tmpDir
112119 removePathForcibly tmpDir
113120 alwaysWriteBugReport tmpDir =
0 commit comments