
+1 for providing an easy way to install an exception handler that uses the display function. You could consider to just provide displayExceptionHandler :: SomeException -> IO () with a hint in the documentation to install it via setUncaughtExceptionHandler displayExceptionHandler That might be slightly more modular, as one could add some pre or post-processing to displayExceptionHandler. Cheers, Andreas On 11.11.2014 03:38, Simon Hengel wrote:
2. Add a function that can be invoked to change the default handler.
like
http://hackage.haskell.org/package/base-4.7.0.1/docs/GHC-Conc-Sync.html#v:se...
I think getting the exception handler right is non-trivial, e.g.
- stdout has to be flushed, ignoring any exceptions while doing so - output has to go to stderr, not stdout - program has to terminate with the correct exit code (at least if it's the main thread) - I would also assume that ExitCode exceptions need special handling, even though I don't see any code for that in the default handler [1], so maybe this is already taken care of before the handler is invoked
So I think it makes sense to provide a primitive along the lines of
useDisplayExceptionHandler :: IO ()
which does "the right thing" (I'm not very opinionated about the name).
One more thing I noticed is that the exception handler set with setUncaughtExceptionHandler is used for both the main thread and other threads. I'm undecided whether this would be desirable or not for useDisplayExceptionHandler. Thoughts?
Cheers, Simon
[1] http://hackage.haskell.org/package/base-4.7.0.1/docs/src/GHC-Conc-Sync.html#...
-- Andreas Abel <>< Du bist der geliebte Mensch. Department of Computer Science and Engineering Chalmers and Gothenburg University, Sweden andreas.abel@gu.se http://www2.tcs.ifi.lmu.de/~abel/