Skip to content

Commit

Permalink
Bug fix: don't explode on non-existing types (GH#576)
Browse files Browse the repository at this point in the history
  • Loading branch information
mickeyn committed May 16, 2017
1 parent 8891d68 commit 2c9b6f8
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion lib/MetaCPAN/Server/Controller.pm
Expand Up @@ -78,7 +78,15 @@ sub mapping : Path('_mapping') {

sub get : Path('') : Args(1) {
my ( $self, $c, $id ) = @_;
my $file = $self->model($c)->raw->get($id);
my $model;

# get a model without exploding when the request
# is for a non-existing type
eval {
$model = $self->model($c);
1;
} or return;
my $file = $model->raw->get($id);
if ( !defined $file ) {
$c->detach( '/not_found', ['Not found'] );
}
Expand Down

0 comments on commit 2c9b6f8

Please sign in to comment.