Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
No need for Try::Tiny when checking if fields were returned.
  • Loading branch information
oalders committed Oct 19, 2014
1 parent b5cb40f commit d424bce
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 11 deletions.
5 changes: 2 additions & 3 deletions lib/MetaCPAN/Server/Controller.pm
Expand Up @@ -8,7 +8,6 @@ use JSON;
use List::MoreUtils ();
use Moose::Util ();
use Moose;
use Try::Tiny;

BEGIN { extends 'Catalyst::Controller'; }

Expand Down Expand Up @@ -81,8 +80,8 @@ sub get : Path('') : Args(1) {
if ( !defined $file ) {
$c->detach( '/not_found', ['Not found'] );
}
try { $c->stash( $file->{_source} || $file->{fields} ) }
or $c->detach( '/not_found',
$c->stash( $file->{_source} || $file->{fields} )
|| $c->detach( '/not_found',
['The requested field(s) could not be found'] );
}

Expand Down
6 changes: 3 additions & 3 deletions lib/MetaCPAN/Server/Controller/Module.pm
Expand Up @@ -4,7 +4,6 @@ use strict;
use warnings;

use Moose;
use Try::Tiny;

BEGIN { extends 'MetaCPAN::Server::Controller::File' }

Expand All @@ -16,9 +15,10 @@ sub get : Path('') : Args(1) {
if ( !defined $file ) {
$c->detach( '/not_found', [] );
}
try { $c->stash( $file->{_source} || $file->{fields} ) }
or $c->detach( '/not_found',
$c->stash( $file->{_source} || $file->{fields} )
|| $c->detach( '/not_found',
['The requested field(s) could not be found'] );
}

__PACKAGE__->meta->make_immutable();
1;
10 changes: 5 additions & 5 deletions lib/MetaCPAN/Server/Controller/Release.pm
Expand Up @@ -4,7 +4,6 @@ use strict;
use warnings;

use Moose;
use Try::Tiny;

BEGIN { extends 'MetaCPAN::Server::Controller' }

Expand All @@ -25,8 +24,8 @@ sub find : Path('') : Args(1) {
if ( !defined $file ) {
$c->detach( '/not_found', [] );
}
try { $c->stash( $file->{_source} || $file->{fields} ) }
or $c->detach( '/not_found',
$c->stash( $file->{_source} || $file->{fields} )
|| $c->detach( '/not_found',
['The requested field(s) could not be found'] );
}

Expand All @@ -41,9 +40,10 @@ sub get : Path('') : Args(2) {
if ( !defined $file ) {
$c->detach( '/not_found', [] );
}
try { $c->stash( $file->{_source} || $file->{fields} ) }
or $c->detach( '/not_found',
$c->stash( $file->{_source} || $file->{fields} )
|| $c->detach( '/not_found',
['The requested field(s) could not be found'] );
}

__PACKAGE__->meta->make_immutable;
1;

0 comments on commit d424bce

Please sign in to comment.