[Haskell-cafe] Catch multiple exceptions using 'Control.Exception'
Roman Cheplyaka
roma at ro-che.info
Thu Jul 4 00:17:52 CEST 2013
* Nikita Karetnikov <nikita at karetnikov.org> [2013-07-03 15:50:16+0400]
> > Perhaps you can use `catches` [0]?
>
> Maybe, but my idea is to replace 'syncExceptions' with a similar
> function. Otherwise, it'll be necessary to change (at least) all
> functions that use 'syncExceptions'. I'd like to avoid that.
Here you go:
import Control.Exception
import Data.Typeable
syncExceptions :: SomeException -> Maybe SomeException
syncExceptions e
| Just _ <- cast e :: Maybe AsyncException = Nothing
| otherwise = Just e
Roman
More information about the Haskell-Cafe
mailing list