parsonsmatt / annotated-exception

Machinery for throwing and catching exceptions with some annotation.
BSD 3-Clause "New" or "Revised" License
32 stars 3 forks source link

Expose a function to remove annotations #26

Open parsonsmatt opened 1 year ago

parsonsmatt commented 1 year ago
import UnliftIO.Exception (catch, throwIO)

removeAnnotationsFromExceptions :: (MonadUnliftIO m) => m a -> m a
removeAnnotationsFromExceptions action = 
    action `catch` \(AnnotatedException _ exn) -> 
      throwIO exn

Would be good to expose this for end users. Tbh I often find myself wanting, like,

mapException :: (Exception e, Exception e') => (e -> e') -> IO a -> IO a

traverseException :: (Exception e, Exception e') => (e -> IO e') -> IO a -> IO a