« Return to Thread: "Use of uninitialized value $buffer" error

Re: "Use of uninitialized value $buffer" error

by Tomas Doran :: Rate this Message:

Reply to Author | View in Thread


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


_______________________________________________
List: Catalyst@...
Listinfo: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst
Searchable archive: http://www.mail-archive.com/catalyst@.../
Dev site: http://dev.catalyst.perl.org/

 « Return to Thread: "Use of uninitialized value $buffer" error