[web-devel] Yesod. Handle Exception.
acheshkov at gmail.com
Tue Jan 25 19:28:29 CET 2011
Thanks. it's convenient.
2011/1/25 Michael Snoyman <michael at snoyman.com>
> 2011/1/25 Антон Чешков <acheshkov at gmail.com>:
> > Hello Michael. Please explain how to handle exceptions in Yesod
> > applications.
> > For example i would to catch the error generated by unique constraint on
> > table.
> > runDB $ insert $ Table field1 field2
> In general, starting with Persistent 0.4, you will want to use the
> monad-peel package, which provides facilities for exception
> catching in wrapped monads. In Persistent 0.3, you can use the
> MonadInvertIO functions available in the neither package.
> MonadInvertIO and MonadPeelIO are very similar in concept, but
> MonadPeelIO is just better.
> But in your particular case, you don't need to resort to runtime
> exceptions: just use insertBy or checkUnique.
>  http://hackage.haskell.org/package/monad-peel
>  I wrote MoandInvertIO, Anders Kaseorg wrote MonadPeelIO, and he's
> smarter than me.
Phone: +7 909 005 18 82
Phone: +7 931 511 47 37
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the web-devel