[Catalyst-commits] r10815 - trunk/misc/exception_test_case_simplest/lib

ferz at dev.catalyst.perl.org ferz at dev.catalyst.perl.org
Tue Jul 7 15:54:06 GMT 2009


Author: ferz
Date: 2009-07-07 15:54:06 +0000 (Tue, 07 Jul 2009)
New Revision: 10815

Removed:
   trunk/misc/exception_test_case_simplest/lib/AraExceptions.pm
Modified:
   trunk/misc/exception_test_case_simplest/lib/TestAppClassException.pm
Log:
Drop unused file and stripped to many %classes not used for this test.


Deleted: trunk/misc/exception_test_case_simplest/lib/AraExceptions.pm
===================================================================
--- trunk/misc/exception_test_case_simplest/lib/AraExceptions.pm	2009-07-07 14:33:39 UTC (rev 10814)
+++ trunk/misc/exception_test_case_simplest/lib/AraExceptions.pm	2009-07-07 15:54:06 UTC (rev 10815)
@@ -1,224 +0,0 @@
-package TestAppClassException::Exceptions;
-
-use strict;
-use warnings;
-
-BEGIN {
-    $Catalyst::Exception::CATALYST_EXCEPTION_CLASS = 'TestAppClassException::Exception';
-
-    my %classes = (
-        'TestAppClassException::Exception' => {
-            description => 'Generic exception',
-            fields      => [ qw( headers status status_message payload ) ],
-            alias       => 'throw'
-        },
-	'TestAppClassException::Exception::SeeOther'=> {
-            isa            => 'TestAppClassException::Exception',
-            description    => '303 - See Other',
-        },
-        'TestAppClassException::Exception::BadRequest' => {
-            isa            => 'TestAppClassException::Exception',
-            description    => '400 - Bad request',
-        },
-        'TestAppClassException::Exception::AccessDenied' => {
-            isa            => 'TestAppClassException::Exception',
-            description    => '401 - Access Denied',
-        },
-        'TestAppClassException::Exception::InsufficientPermission' => {
-            isa            => 'TestAppClassException::Exception',
-            description    => '403 - Insufficient Permission',
-        },
-        'TestAppClassException::Exception::FileNotFound' => {
-            isa            => 'TestAppClassException::Exception',
-            description    => '404 - File Not Found',
-        },
-        'TestAppClassException::Exception::PreconditionFailed' => {
-            isa            => 'TestAppClassException::Exception',
-            description    => '412 - Precondition Failed',
-        },
-    );
-
-    my @exports = grep { defined } map { $classes{ $_ }->{ alias } } keys %classes;
-
-    require Exception::Class;
-    require Sub::Exporter;
-
-    Exception::Class->import(%classes);
-    Sub::Exporter->import( -setup => { exports => \@exports  } );
-}
-
-package TestAppClassException::Exception;
-
-## thank to Brian
-## http://bricas.vox.com/library/post/catalyst-exceptionclass.html
-
-use strict;
-use warnings;
-no warnings 'redefine';
-
-use HTTP::Headers ();
-use HTTP::Status  ();
-use Scalar::Util  qw( blessed );
-#use parent 'Exception::Class';
-
-sub headers {
-    my $self    = shift;
-    my $headers = $self->{headers};
-
-    unless ( defined $headers ) {
-        return undef;
-    }
-
-    if ( blessed $headers && $headers->isa('HTTP::Headers') ) {
-        return $headers;
-    }
-
-    if ( ref $headers eq 'ARRAY' ) {
-        return $self->{headers} = HTTP::Headers->new( @{ $headers } );
-    }
-
-    if ( ref $headers eq 'HASH' ) {
-        return $self->{headers} = HTTP::Headers->new( %{ $headers } );
-    }
-
-
-    AraException->throw(
-        message => qq(Can't coerce a '$headers' into a HTTP::Headers instance.)
-    );
-}
-
-sub status {
-    return $_[0]->{status} ||= 500;
-}
-
-sub is_info {
-    return HTTP::Status::is_info( $_[0]->status );
-}
-
-sub is_success {
-    return HTTP::Status::is_success( $_[0]->status );
-}
-
-sub is_redirect {
-    return HTTP::Status::is_redirect( $_[0]->status );
-}
-
-sub is_error {
-    return HTTP::Status::is_error( $_[0]->status );
-}
-
-sub is_client_error {
-    return HTTP::Status::is_client_error( $_[0]->status );
-}
-
-sub is_server_error {
-    return HTTP::Status::is_server_error( $_[0]->status );
-}
-
-sub status_line {
-    $DB::single=1;
-    return sprintf "%s %s", $_[0]->status, $_[0]->status_message;
-}
-
-sub status_message {
-    return $_[0]->{status_message} ||= HTTP::Status::status_message( $_[0]->status );
-}
-
-my %messages = (
-    400 => 'Browser sent a request that this server could not understand.',
-    401 => 'The requested resource requires user authentication.',
-    403 => 'Insufficient permission to access the requested resource on this server.',
-    404 => 'The requested resource was not found on this server.',
-    405 => 'The requested method is not allowed.',
-    500 => 'The server encountered an internal error or misconfiguration and was unable to complete the request.',
-    501 => 'The server does not support the functionality required to fulfill the request.',
-);
-
-sub public_message {
-    return $messages{ $_[0]->status } || 'An error occurred.';
-}
-
-sub as_public_html {
-    my $self    = shift;
-    $DB::single=1;
-    my $title   = shift || $self->status_line;
-    my $header  = shift || $self->status_message;
-    my $message = shift || $self->public_message;
-
-return <<EOF;
-<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
-<html>
-  <head>
-    <title>$title</title>
-  </head>
-  <body>
-    <h1>$header</h1>
-    <p>$message</p>
-  </body>
-</html>
-EOF
-
-}
-
-sub has_headers {
-    return defined $_[0]->{headers} ? 1 : 0;
-}
-
-sub has_payload {
-    return defined $_[0]->{payload} && length $_[0]->{payload} ? 1 : 0;
-}
-
-sub has_status_message {
-    return defined $_[0]->{status_message} ? 1 : 0;
-}
-
-sub full_message {
-    my $self    = shift;
-    my $message = $self->message;
-
-    if ( $self->has_payload ) {
-        $message .= sprintf " %s.", $self->payload;
-    }
-
-    return $message;
-}
-
-
-package TestAppClassException::Exception::FileNotFound;
-
-sub status {
-    return $_[0]->{status} ||= 404;
-}
-
-package TestAppClassException::Exception::AccessDenied;
-
-sub status {
-    return $_[0]->{status} ||= 401;
-}
-
-package TestAppClassException::Exception::InsufficientPermission;
-
-sub status {
-    return $_[0]->{status} ||= 403;
-}
-
-package TestAppClassException::Exception::PreconditionFailed;
-
-sub status {
-    return $_[0]->{status} ||= 412;
-}
-
-package TestAppClassException::Exception::SeeOther;
-
-sub status {
-    return $_[0]->{status} ||= 303;
-}
-
-package TestAppClassException::Exception::BadRequest;
-
-sub status {
-    return $_[0]->{status} ||= 400;
-}
-
-
-1;

Modified: trunk/misc/exception_test_case_simplest/lib/TestAppClassException.pm
===================================================================
--- trunk/misc/exception_test_case_simplest/lib/TestAppClassException.pm	2009-07-07 14:33:39 UTC (rev 10814)
+++ trunk/misc/exception_test_case_simplest/lib/TestAppClassException.pm	2009-07-07 15:54:06 UTC (rev 10815)
@@ -12,30 +12,10 @@
             fields      => [ qw( headers status status_message payload ) ],
             alias       => 'throw'
         },
-	'TestAppClassException::Exception::SeeOther'=> {
-            isa            => 'TestAppClassException::Exception',
-            description    => '303 - See Other',
-        },
         'TestAppClassException::Exception::BadRequest' => {
             isa            => 'TestAppClassException::Exception',
             description    => '400 - Bad request',
         },
-        'TestAppClassException::Exception::AccessDenied' => {
-            isa            => 'TestAppClassException::Exception',
-            description    => '401 - Access Denied',
-        },
-        'TestAppClassException::Exception::InsufficientPermission' => {
-            isa            => 'TestAppClassException::Exception',
-            description    => '403 - Insufficient Permission',
-        },
-        'TestAppClassException::Exception::FileNotFound' => {
-            isa            => 'TestAppClassException::Exception',
-            description    => '404 - File Not Found',
-        },
-        'TestAppClassException::Exception::PreconditionFailed' => {
-            isa            => 'TestAppClassException::Exception',
-            description    => '412 - Precondition Failed',
-        },
     );
 
     my @exports = grep { defined } map { $classes{ $_ }->{ alias } } keys %classes;
@@ -81,7 +61,6 @@
         return $self->{headers} = HTTP::Headers->new( %{ $headers } );
     }
 
-
     AraException->throw(
         message => qq(Can't coerce a '$headers' into a HTTP::Headers instance.)
     );
@@ -228,7 +207,7 @@
 use warnings;
 
 
-use AraExceptions;
+#use TestAppClassException::Exceptions;
 
 use Scalar::Util ();
 use Catalyst::Runtime '5.80';




More information about the Catalyst-commits mailing list