-
Notifications
You must be signed in to change notification settings - Fork 376
Description
annotated-exception wraps exceptions in a semipermeable AnnotatedException e type, such that catching AnnotatedException e will also catch a thrown e (and provide a mempty for the annotations). So,
catchAnnotated :: Exception e => IO a -> (AnnotatedException e -> IO a) -> IO a
catchAnnotated = Control.Exception.catchwill never let an e escape.
However, only the catch and try functions in annotated-exception will also "see through" the AnnotatedException e and allow you to catch a plain e.
catchUnAnnotated :: Exception e => IO a (e -> IO a) -> IO a
catchUnAnnotated = Control.Exception.Annotated.catchyesod currently uses HandlerContents as an exception to short-circuit execution of a handler. If an application is using AnnotatedException, then the current exception catching facilities will fail to handle an AnnotatedException HandlerContents as a HandlerContents, and will instead fail.
You can work around this by defining an exception handling middleware:
removeAnnotatedException :: HandlerFor site a -> HandlerFor site a
removeAnnotatedException action =
action `catch` \(AnnotatedException _ (e :: SomeException)) ->
throwIO eBut this would "just work" if yesod were integrated with annotated-exception, if only to catch the HandlerContents.