On 11/1/06, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote:
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).
Yes, eval is generally the way to go, as DBIC will throw exceptions on errors.
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
- 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 [EMAIL PROTECTED])
?
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
_______________________________________________ List: http://lists.rawmode.org/cgi-bin/mailman/listinfo/dbix-class Wiki: http://dbix-class.shadowcatsystems.co.uk/ IRC: irc.perl.org#dbix-class SVN: http://dev.catalyst.perl.org/repos/bast/trunk/DBIx-Class/ Searchable Archive: http://www.mail-archive.com/[email protected]/
