Permalink
Browse files

Prepend 404 messages with a "Not found: " string, fill in an error (o…

…r the class name) if present.
  • Loading branch information...
1 parent b3ffe06 commit ea0bf469dcc26c7327ff5b8e31ecf4a431ed8e9b @wolfsage committed Mar 30, 2012
Showing with 5 additions and 3 deletions.
  1. +1 −1 lib/MetaCPAN/Server/Controller/Root.pm
  2. +4 −2 t/server/controller/pod.t
View
2 lib/MetaCPAN/Server/Controller/Root.pm
@@ -12,7 +12,7 @@ sub default : Path {
sub not_found : Private {
my ( $self, $c, $message ) = @_;
$c->clear_stash;
- $c->stash( { message => $message || 'Not found' } );
+ $c->stash( { message => "Not found: " . ($message || "No error...") } );
$c->response->status(404);
$c->forward($c->view('JSON'));
}
View
6 t/server/controller/pod.t
@@ -11,7 +11,7 @@ $fh->close;
my %tests = (
# TODO
- #'/pod' => 404,
+ #'/pod' => 404,
'/pod/DOESNEXIST' => 404,
'/pod/Moose' => 200,
'/pod/DOY/Moose-0.01/lib/Moose.pm' => 200,
@@ -32,14 +32,16 @@ test_psgi app, sub {
);
if($k eq '/pod/Pod::Pm') {
like( $res->content, qr/Pod::Pm - abstract/, 'NAME section' );
- } elsif ( $v eq 200 ) {
+ } elsif ( $v == 200 ) {
like( $res->content, qr/Moose - abstract/, 'NAME section' );
ok( $res = $cb->( GET "$k?content-type=text/plain" ),
"GET plain" );
is( $res->header('content-type'),
'text/plain; charset=UTF-8',
'Content-type'
);
+ } elsif ( $v == 404 ) {
+ like( $res->content, qr/Not found: (\w+)/, "404 correct error");
}
my $ct = $k =~ /Moose[.]pm$/ ? '&content-type=text/x-pod' : '';

0 comments on commit ea0bf46

Please sign in to comment.