You want to use liftIOHandler[1]. You should be able to just do:

    function = liftIOHandler $ do ...

However, given that you want to call runDB, which *already* has a call to liftIOHandler, I'd recommend you take the code from runDB and modify it.

Michael

[1] http://hackage.haskell.org/packages/archive/yesod-core/0.8.1/doc/html/Yesod-Handler.html#v:liftIOHandler

On Tue, May 17, 2011 at 3:04 PM, Anton Cheshkov <acheshkov@gmail.com> wrote:
Hi Michael, 

i need to handle exception on GHandler monad level.

We have: 

type GHandler sub master = GGHandler sub master (Iteratee ByteString IO)

data GGHandler sub master m a
     ...
            MonadControlIO m => MonadControlIO (GGHandler sub master m)


(Iteratee ByteString IO) have no instance of  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