Skip to content

Commit 5db82a3

Browse files
committed
No need for Try::Tiny when checking if fields were returned.
1 parent a97a9ae commit 5db82a3

File tree

3 files changed

+10
-11
lines changed

3 files changed

+10
-11
lines changed

lib/MetaCPAN/Server/Controller.pm

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ use JSON;
88
use List::MoreUtils ();
99
use Moose::Util ();
1010
use Moose;
11-
use Try::Tiny;
1211

1312
BEGIN { extends 'Catalyst::Controller'; }
1413

@@ -81,8 +80,8 @@ sub get : Path('') : Args(1) {
8180
if ( !defined $file ) {
8281
$c->detach( '/not_found', ['Not found'] );
8382
}
84-
try { $c->stash( $file->{_source} || $file->{fields} ) }
85-
or $c->detach( '/not_found',
83+
$c->stash( $file->{_source} || $file->{fields} )
84+
|| $c->detach( '/not_found',
8685
['The requested field(s) could not be found'] );
8786
}
8887

lib/MetaCPAN/Server/Controller/Module.pm

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ use strict;
44
use warnings;
55

66
use Moose;
7-
use Try::Tiny;
87

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

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

23+
__PACKAGE__->meta->make_immutable();
2424
1;

lib/MetaCPAN/Server/Controller/Release.pm

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ use strict;
44
use warnings;
55

66
use Moose;
7-
use Try::Tiny;
87

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

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

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

48+
__PACKAGE__->meta->make_immutable;
4949
1;

0 commit comments

Comments
 (0)