From ff1acd5f0e81b8d9e2bea74f14f5f583e4af75c1 Mon Sep 17 00:00:00 2001 From: Mike Pilgrem Date: Tue, 20 Dec 2022 20:02:14 +0000 Subject: [PATCH] Fix #5978 Accommodate pretty exceptions with --file-watch --- ChangeLog.md | 4 ++++ src/Stack/FileWatch.hs | 17 +++++++++-------- 2 files changed, 13 insertions(+), 8 deletions(-) diff --git a/ChangeLog.md b/ChangeLog.md index 3d8d21d5b8..ccea38047c 100644 --- a/ChangeLog.md +++ b/ChangeLog.md @@ -14,6 +14,10 @@ Other enhancements: Bug fixes: +* `stack build` with `--file-watch` or `--file-watch-poll` outputs 'pretty' + error messages, as intended. See + [#5978](https://github.com/commercialhaskell/stack/issues/5978). + ## v2.9.3 Release notes: diff --git a/src/Stack/FileWatch.hs b/src/Stack/FileWatch.hs index 0d4813011e..02fc574c85 100644 --- a/src/Stack/FileWatch.hs +++ b/src/Stack/FileWatch.hs @@ -125,13 +125,14 @@ fileWatchConf cfg inner = -- https://github.com/commercialhaskell/stack/issues/822 atomically $ writeTVar dirtyVar False - prettyInfo $ - case eres of - Left e -> - let theStyle = case fromException e of - Just ExitSuccess -> Good - _ -> Error - in style theStyle $ fromString $ displayException e - _ -> style Good "Success! Waiting for next file change." + case eres of + Left e -> + case fromException e of + Just ExitSuccess -> + prettyInfo $ style Good $ fromString $ displayException e + _ -> case fromException e :: Maybe PrettyException of + Just pe -> prettyError $ pretty pe + _ -> prettyInfo $ style Error $ fromString $ displayException e + _ -> prettyInfo $ style Good "Success! Waiting for next file change." logInfo "Type help for available commands. Press enter to force a rebuild."