ivan-m / graphviz

Haskell bindings to the Graphviz toolkit
Other
64 stars 24 forks source link

replace mapException with handle #45

Closed kderme closed 4 years ago

kderme commented 5 years ago

runGraphviz and related functions seem to throw IOException instead of GraphvizException when dot executable is missing. I think this happens because mapException is only indented to handle imprecise exceptions:

data ExceptionA = ExceptionA
    deriving (Show, Typeable, Exception)

data ExceptionB = ExceptionB
    deriving (Show, Typeable, Exception)

reify :: ExceptionA -> ExceptionB
reify ExceptionA = ExceptionB

mapException reify $ throwIO ExceptionA
  -> throws ExceptionA

mapException reify $ throw ExceptionA
  -> throws ExceptionB

mapException reify $ ((throw ExceptionA) :: IO ())
  -> throws ExceptionB

In this pr I use handle instead.

Btw, thanks for this library!