X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=lib%2FCatalyst%2FException.pm;h=4959e4209e047c3127ade536d31cd0b3e9d9f9bb;hb=0af1b40c4ce16ae21702b9989357d76ebcec2153;hp=fe1f5fdb4046d10742588606fd392e89712fb66f;hpb=536bee890cf24e0e4bcda7562e7b70cc03ca0620;p=catagits%2FCatalyst-Runtime.git diff --git a/lib/Catalyst/Exception.pm b/lib/Catalyst/Exception.pm index fe1f5fd..4959e42 100644 --- a/lib/Catalyst/Exception.pm +++ b/lib/Catalyst/Exception.pm @@ -5,7 +5,8 @@ package Catalyst::Exception; package Catalyst::Exception::Base; use Moose; -use Carp (); +use Carp; +use namespace::clean -except => 'meta'; =head1 NAME @@ -33,6 +34,18 @@ Throws a fatal exception. =cut +has message => ( + is => 'ro', + isa => 'Str', +); + +use overload q{""} => \&as_string; + +sub as_string { + my ($self) = @_; + return $self->message; +} + sub throw { my $class = shift; my %params = @_ == 1 ? ( error => $_[0] ) : @_; @@ -41,7 +54,7 @@ sub throw { local $Carp::CarpLevel = 1; - Carp::croak($message); + croak($message); } =head2 meta @@ -64,13 +77,14 @@ Catalyst::Exception::Base->meta->make_immutable; package Catalyst::Exception; use Moose; +use namespace::clean -except => 'meta'; + use vars qw[$CATALYST_EXCEPTION_CLASS]; BEGIN { extends($CATALYST_EXCEPTION_CLASS || 'Catalyst::Exception::Base'); } -no Moose; __PACKAGE__->meta->make_immutable; 1;