summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--lib/Net/HTTP/Spore.pm15
-rw-r--r--t/spore/02_enable.t6
2 files changed, 10 insertions, 11 deletions
diff --git a/lib/Net/HTTP/Spore.pm b/lib/Net/HTTP/Spore.pm
index 87454c9..5c4f0c7 100644
--- a/lib/Net/HTTP/Spore.pm
+++ b/lib/Net/HTTP/Spore.pm
@@ -88,13 +88,8 @@ sub _attach_spec_to_class {
     };
 
     try {
-        my $base_url;
-        if ( $spec->{base_url} && !$opts->{base_url} ) {
-            $opts->{base_url} = $spec->{base_url};
-        }
-        elsif ( !$opts->{base_url} ) {
-            die "base_url is missing!";
-        }
+        $opts->{base_url} ||= $spec->{base_url};
+        die "base_url is missing!" if !$opts->{base_url};
 
         if ( $spec->{formats} ) {
             $opts->{formats} = $spec->{formats};
@@ -126,6 +121,10 @@ sub _read_spec {
         my $req = HTTP::Request->new( GET => $spec_file );
         my $ua  = LWP::UserAgent->new();
         my $res = $ua->request($req);
+        unless( $res->is_success ) {
+            my $status = $res->status_line;
+            Carp::confess("Unabled to fetch $spec_file ($status)");
+        }
         $content = $res->content;
     }
     else {
@@ -215,7 +214,7 @@ L<Net::HTTP::Spore> provides a way to trace what's going on when doing a request
 
 =head3 Enabling Trace
 
-You can enable tracing using the environment variable B<SPORE_TRACE>. You can also enable tracing at construct time by adding B<trace =E-<GT> 1> when calling B<new_from_spec>.
+You can enable tracing using the environment variable B<SPORE_TRACE>. You can also enable tracing at construct time by adding B<trace =E<gt> 1> when calling B<new_from_spec>.
 
 =head3 Trace Output
 
diff --git a/t/spore/02_enable.t b/t/spore/02_enable.t
index 2bd7402..e54d7a3 100644
--- a/t/spore/02_enable.t
+++ b/t/spore/02_enable.t
@@ -26,15 +26,15 @@ is scalar @{$client->middlewares}, 0, 'no middleware';
 
 dies_ok {
     $client->enable();
-}, 'middleware name is required';
+} 'middleware name is required';
 
 dies_ok {
     $client->enable('FOOBARBAZAWESOMEMIDDLEWARE');
-}, 'middleware should be loadable';
+} 'middleware should be loadable';
 
 dies_ok {
     $client->enable_if('Format::JSON');
-}, 'enable if require a coderef';
+} 'enable if require a coderef';
 
 $client->enable('Dummy');
 is scalar @{$client->middlewares}, 1, 'middleware dummy added';