Skip Menu |

This queue is for tickets about the Class-Std CPAN distribution.

Report information
The Basics
Id: 18747
Status: open
Priority: 0/
Queue: Class-Std

People
Owner: Nobody in particular
Requestors: bsdguru [...] cox.net
Cc:
AdminCc:

Bug Information
Severity: Normal
Broken in: v0.0.8
Fixed in: (no value)



Subject: croak reports in the context of Class::Std instead of caller
Calling croak inside a BUILD block reports the error at Class:std line 438 instead of the line from the calling package. use Class::Std { my (%file_of,) :ATTRS; sub BUILD { my ($self, $oid, $arg_ref) = @_; $file_of{$oid} = $arg_ref{file} or croak "Missing initializer"; } } This is a very simple example and init_arg would work but croaking on more complex initialization yields difficult to trace error messages. Perl v. 5.8.7 Carp v. 1.0.4 FreeBSD 6.0-STABLE
From: sullivam [...] yahoo-inc.com
On Mon Apr 17 01:17:48 2006, guest wrote: Show quoted text
> Calling croak inside a BUILD block reports the error at Class:std line > 438 instead of the line from the calling package.
FWIW, I get around this for now with: our @CARP_NOT = qw( Class::Std );
Subject: Re: [rt.cpan.org #18747] croak reports in the context of Class::Std instead of caller
Date: Wed, 3 May 2006 20:43:44 -0400
To: bug-Class-Std [...] rt.cpan.org
From: Trevor Cornpropst <bsdguru [...] cox.net>
On Mon, 1 May 2006 20:06:37 -0400 (EDT) "Guest via RT" <bug-Class-Std@rt.cpan.org> wrote: Show quoted text
> > <URL: http://rt.cpan.org/Ticket/Display.html?id=18747 > > > On Mon Apr 17 01:17:48 2006, guest wrote:
> > Calling croak inside a BUILD block reports the error at Class:std line > > 438 instead of the line from the calling package.
> > FWIW, I get around this for now with: > > our @CARP_NOT = qw( Class::Std );
-- Thanks for the tip. I'll give it a try.
On Mon Apr 17 01:17:48 2006, guest wrote: Show quoted text
> Calling croak inside a BUILD block reports the error at Class:std line > 438 instead of the line from the calling package.
Class::Std *is* calling BUILD so if you croak and want ot to come from where new() is being called you need to: sub BUILD { local $Carp::CarpLevel = $Carp::CarpLevel + 1; ... carp 'whatever' if $whatever; } Perhaps we can add this automatically or shall it stay as part of due diligence?
CC: JDHEDDEN [...] cpan.org
Subject: Re: [rt.cpan.org #18747] croak reports in the context of Class::Std instead of caller
Date: Sat, 16 Jun 2007 00:09:52 -0400
To: bug-Class-Std [...] rt.cpan.org
From: Trevor Cornpropst <bsdguru [...] cox.net>
On Sun, 10 Dec 2006 01:25:06 -0500 " via RT" <bug-Class-Std@rt.cpan.org> wrote: Show quoted text
> > <URL: http://rt.cpan.org/Ticket/Display.html?id=18747 > > > On Mon Apr 17 01:17:48 2006, guest wrote:
> > Calling croak inside a BUILD block reports the error at Class:std line > > 438 instead of the line from the calling package.
> > Class::Std *is* calling BUILD so if you croak and want ot to come from where new() is being > called you need to: > > sub BUILD { > local $Carp::CarpLevel = $Carp::CarpLevel + 1; > ... > carp 'whatever' if $whatever; > > } > > Perhaps we can add this automatically or shall it stay as part of due diligence?
This is something I should have caught. It makes sense. I suggest it should be added automatically because that is the expected behavior. Either way, it should be documented in the POD. Thank you for clearing this up. --