esharris has asked for the wisdom of the Perl Monks concerning the following question:

The Exception::Class::throw method saves the line number like "die". To save the line number like "croak", I have to use croak.

MYException->throw();
... becomes ...
croak(MyException->new());
Is there a more elegant solution?

Replies are listed 'Best First'.
Re: Exception::Class croak?
by PreferredUserName (Pilgrim) on Jan 20, 2006 at 16:50 UTC
    See the builtin function "caller()" for getting to the information that croak() usually prints.
Re: Exception::Class croak?
by jdhedden (Deacon) on Jan 20, 2006 at 21:32 UTC
    The ignore_class and ignore_package parameters are useful for this.
    MyException->throw('ignore_package' => __PACKAGE__);
    These are documented in Devel::Stacktrace.

    Remember: There's always one more bug.