Skip to content

Commit

Permalink
Merge pull request #652 from metacpan/mickey/GH576_bug_fix
Browse files Browse the repository at this point in the history
Bug fix: don't explode on non-existing types (GH#576)
  • Loading branch information
oalders committed May 17, 2017
2 parents b5615e9 + 2c9b6f8 commit 34dde30
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 34dde30

Please sign in to comment.