[Catalyst] "Use of uninitialized value $buffer" error

Tomas Doran bobtfish at bobtfish.net
Sun Jun 28 14:20:54 GMT 2009


On 26 Jun 2009, at 17:06, Merlyn Kline wrote:

>>> being. Basically, though, the obvious proximal cause of this  
>>> would be
>>> calling the write method with no parameter. This might seem an
> [snip]
>
>> I'm afraid this isn't too helpful for me at least; in this
>> case I'm just an end user, not doing anything fancy here, so
>
> Presumably you *aren't*, in fact, calling the write method with no
> parameters (or an undef), accidentally or otherwise?
>
> Or perhaps another way to trigger this would be to set some headers  
> and then
> never call the write method, so the attempt to flush the headers  
> would end
> up in the code you cited with no buffer defined.

I'd be adding something like this to your MyApp.pm:

use Moose; # To the top :)

# N.B. This has to go after __PACKAGE__->setup;
before 'write' => sub {
     my ($self, $buf) = @_;
     Carp::cluck("write method called with undef buffer") if !defined  
$buf;
};

This should at least prove or disprove the 'write with undef' theory  
(you should see the warning, and a stack trace just before your  
undefined value warning), and should give you some insight into  
whodunnit from the stack trace if the hypothesis is true..

Cheers
t0m




More information about the Catalyst mailing list