[Dbix-class] Newcomer questions ?

Brandon Black blblack at gmail.com
Wed Nov 1 20:42:26 GMT 2006


On 11/1/06, Ivan.Georgiev at uboc.com <Ivan.Georgiev at uboc.com> wrote:

> - will transactions work on mysql (myisam)
> if I use them like specified in the example i found somewhere in the
> docs:)
> ?
> (MyISAM doesn't support transactions.)


If the underlying DB doesn't properly support transactions, they won't work
from DBIC either (at least not safely like they're supposed to).

- How do you handle errors (like any other perl code i.e. eval{}; if $@...)
> ?


Yes, eval is generally the way to go, as DBIC will throw exceptions on
errors.

  OR there a central place I can catch the errors ? ...
>   mmm, sorry I saw there is exception_action() in dbix::class::schema ;)


exception_action is really meant for making DBIC throw custom exception
objects as opposed to a plain croak().  Ideally the coderef you hook into
there should rethrow the exception itself after doing whatever it does
(wrapping it in an exception object, logging something to disk, etc).  If
your code fails to rethrow and instead returns, DBIC's behavior is dependant
on your return value.  Returning false will cause DBIC to throw the original
exception just like it would have anyways, and returning true will suppress
the exception.  Actually suppressing exceptions via this mechanism is
dangerous for your application's health, and shouldn't be done unless you're
really sure of what you're doing and are very selective about what you
suppress.

-- Brandon
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://jules.scsys.co.uk/pipermail/dbix-class/attachments/20061101/46f=
c2b44/attachment.htm


More information about the Dbix-class mailing list