On Mar 14, 2008, at 1:36 PM, Aristotle Pagaltzis wrote:
* Ashley <[EMAIL PROTECTED]> [2008-03-14 16:40]:
I've been threatening for more than a year to write a plugin to
do this. I wrote to ask for CPAN/method name suggestions,
Aristotle gave me good advice which I'll have to dig up.

you mean this:

* Aristotle Pagaltzis <[EMAIL PROTECTED]> [2007-07-17 00:25]:
I’d rather call it FatalErrorThrow and the method would be
`fatal_error`, I think.


While we're on the topic. How abhorrent/stupid is this?
       $c->die();
   # or
       $c->die("Dying is easy, comedy is hard");

I'd really like something like this. I could go for $c->fatal() too.
fatal_error() is nice and descriptive but I lean toward something
shorter if it can be agreed upon.

It should convey, /somehow/, that it's circumventing further processing
excepting the end. "die" feels intuitive and is super easy to type but
it seems too loaded. Please give me insight, sanction, corrections,
spankings, declarations regarding how I'll never work in this town
again et cetera and so forth.

The code below is *barely* tested.

package Catalyst::Plugin::Die;
use strict;
use warnings;

BEGIN {
    no strict "vars";
push(@ISA, $Catalyst::Exception::CATALYST_EXCEPTION_CLASS || 'Catalyst::Exception::Base');
}

sub die : method {
    my $self = shift;
    my %params = @_ == 1 ? ( error => $_[0] ) : @_;
my $message = $params{message} || $params{error} || $! || "Catalyst::Plugin::Die->die called";

    eval { $self->throw($message) };

    $self->error($@ || "Unknown error in Catalyst::Plugin::Die->die");

    $self->NEXT::die(@_);
    $self->detach;  # $self->detach("end") ???
}

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

Reply via email to