[web-devel] Exception Handling on GHandler monad level

Anton Cheshkov acheshkov at gmail.com
Tue May 17 14:04:03 CEST 2011


Hi Michael,

i need to handle exception on GHandler monad level.

We have:

*type GHandler sub master =
GGHandler<http://hackage.haskell.org/packages/archive/yesod-core/0.8.1/doc/html/Yesod-Handler.html#t:GGHandler>
sub
master (Iteratee<http://hackage.haskell.org/packages/archive/enumerator/0.4.10/doc/html/Data-Enumerator.html#t:Iteratee>
 ByteString<http://hackage.haskell.org/packages/archive/bytestring/0.9.1.10/doc/html/Data-ByteString.html#t:ByteString>
 IO<http://hackage.haskell.org/packages/archive/base/4.3.1.0/doc/html/System-IO.html#t:IO>
**)*
*
*data GGHandler sub master m a
     ...
            MonadControlIO<http://hackage.haskell.org/packages/archive/monad-control/0.2.0.1/doc/html/Control-Monad-IO-Control.html#t:MonadControlIO>
m
=> MonadControlIO<http://hackage.haskell.org/packages/archive/monad-control/0.2.0.1/doc/html/Control-Monad-IO-Control.html#t:MonadControlIO>
 (GGHandler<http://hackage.haskell.org/packages/archive/yesod-core/0.8.1/doc/html/Yesod-Handler.html#t:GGHandler>
sub
master m)


*(Iteratee<http://hackage.haskell.org/packages/archive/enumerator/0.4.10/doc/html/Data-Enumerator.html#t:Iteratee>
 ByteString<http://hackage.haskell.org/packages/archive/bytestring/0.9.1.10/doc/html/Data-ByteString.html#t:ByteString>
 IO<http://hackage.haskell.org/packages/archive/base/4.3.1.0/doc/html/System-IO.html#t:IO>
**) have no instance of *
MonadControlIO<http://hackage.haskell.org/packages/archive/monad-control/0.2.0.1/doc/html/Control-Monad-IO-Control.html#t:MonadControlIO>
thus
we got error:

No instance for (MonadControlIO
                       (Data.Enumerator.Iteratee
Data.ByteString.Internal.ByteString IO))
      arising from a use of `E.catch'
    Possible fix:
      add an instance declaration for
      (MonadControlIO
         (Data.Enumerator.Iteratee Data.ByteString.Internal.ByteString IO))


i need something like:
*
*
*function :: Handler (Maybe Int)*
*function = do *
*            res <- E.catch (runDB $ do *
*                            action1*
*                            action2*
*                            ... *
*                            return 1*
*                   )*
*                   (\(e :: E.SomeException) -> return 0)*


How i can get this ?

Thanks.

-- 
Best regards,
Cheshkov Anton
Phone: +7 909 005 18 82
Skype: cheshkov_anton
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.haskell.org/pipermail/web-devel/attachments/20110517/5ad5c7d6/attachment.htm>


More information about the web-devel mailing list