Skip to content

Commit

Permalink
fixup! Print unhandled exception to stdout depending on verbosity
Browse files Browse the repository at this point in the history
  • Loading branch information
cblp committed Feb 13, 2024
1 parent 910ca3d commit b098474
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion Web/Scotty/Action.hs
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@ import Numeric.Natural
import Web.Scotty.Internal.Types
import Web.Scotty.Util (mkResponse, addIfNotPresent, add, replace, lazyTextToStrictByteString, decodeUtf8Lenient)

Check warning on line 99 in Web/Scotty/Action.hs

View workflow job for this annotation

GitHub Actions / ubuntu-latest / ghc 9.4.6

The import of ‘decodeUtf8Lenient’

Check warning on line 99 in Web/Scotty/Action.hs

View workflow job for this annotation

GitHub Actions / ubuntu-latest / ghc 9.6.3

The import of ‘decodeUtf8Lenient’

Check warning on line 99 in Web/Scotty/Action.hs

View workflow job for this annotation

GitHub Actions / ubuntu-latest / ghc 9.6.2

The import of ‘decodeUtf8Lenient’
import UnliftIO.Exception (Handler(..), catch, catches, throwIO)
import System.IO (hPutStrLn, stderr)

import Network.Wai.Internal (ResponseReceived(..))

Expand Down Expand Up @@ -179,7 +180,8 @@ someExceptionHandler Options{verbose} =
Handler $ \(E.SomeException e) -> do
when (verbose > 0) $
liftIO $
putStrLn $ "Caught and exception of " <> show (typeOf e) <> ": " <> show e
hPutStrLn stderr $
"Unhandled exception of " <> show (typeOf e) <> ": " <> show e
status status500

-- | Throw a "500 Server Error" 'StatusError', which can be caught with 'catch'.
Expand Down

0 comments on commit b098474

Please sign in to comment.