[Dbix-class] exception_action fail after DBIC upgrade

Peter Rabbitson rabbit+dbic at rabbit.us
Mon Jan 21 22:21:42 GMT 2013


On Tue, Jan 22, 2013 at 01:23:51AM +0400, Konstantin A. Pustovalov wrote:
> 
> >>Hi!
> >>
> >>Sorry for being silent. Loong russian holidays, you know )
> >>But I have investigated a little. DBIC seems to not notice the
> >>exception if it (exeption) stringifies to zero length string. That
> >>was OK for my code since all error info was coded into exception
> >>type. Till DBIC upgrade. The fix was to add some message to all
> >>exceptions. Should I still pull test to fixate 0.08196 behavior?
> >Yes please. While this is ultimately a problem with your code (an
> >exception may *never* stringify to "", read `perldoc -f eval` for the
> >exact reason why), I still want to get DBIC to handle it correctly.
> >
> >Cheers
> >
> If you mean this snip from the doc:
> >  If there was no error, $@ is guaranteed to be the empty string
> 
> then this is not my case.

It actually is, you are just not looking at it from the viewpoint of
an external developer.

> Object which stringifies to empty string
> is definitely not the same as empty string (the former is true value
> while latter is not).

Yes, except that it is a flawed assumption that folks check for 
"truthiness" of $@. In fact any code that does this (if ($@) { ... }) is 
arguably wrong. The only correct way to check for an exception is (if 
($@ eq '') { ... } ) after an eval just took place. At which point you 
are landing straight into the trap that your exception objects are. Here 
is a little nonexhaustive search to convince you that the problem is not 
just academical [1]

Which brings me to your pull request - it can't be accepted as-is. The 
case of a ''-stringifying object is not business as usual. Hence the 
test you added needs to be tweaked to expect a *dfferent* exception, 
saying something like "Your exception thrown blah blah stringifies to 
the empty string - this is not ok, fix your exception library. Original 
exception was Foo::Bar=HASH(0x9bb77d0)." Or something like that.

[1] http://is.gd/RRXRpf



More information about the DBIx-Class mailing list