PROPOSAL: Add displayException to Exception typeclass
Felipe Lessa
felipe.lessa at gmail.com
Tue Nov 11 13:04:52 UTC 2014
On 11-11-2014 04:40, Andreas Abel wrote:
> +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 ()
Even better, why not
stderrExceptionHandler
:: (SomeException -> String) -> SomeException -> IO ()
Then it's trivial to define:
defaultExceptionHandler = stderrExceptionHandler show
displayExceptionHandler = stderrExceptionHandler display
Or anything else you may want, for that matter. In particular:
foobarExceptionHandler = stderrExceptionHandler mkMsg
where
ruler = replicate 60 '-'
mkMsg exc =
unlines
[ ruler
, "Sorry, an unexpected error occurred. Please "
, "file an issue at https://bugs.example.com/"
, "with the following message attached:"
, ruler
, display exc -- Use both for
, show exc -- good measure :P.
, ruler ]
An easy way of installing a custom exception handler that directs the
user towards the application's developers :).
Cheers,
--
Felipe.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: OpenPGP digital signature
URL: <http://www.haskell.org/pipermail/libraries/attachments/20141111/dd044aa5/attachment.sig>
More information about the Libraries
mailing list