annotated-exception icon indicating copy to clipboard operation
annotated-exception copied to clipboard

Expose a function to remove annotations

Open parsonsmatt opened this issue 2 years ago • 0 comments

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

parsonsmatt avatar Jul 25 '23 19:07 parsonsmatt