Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Oops, FetchError is public API. Have my cake and eat it too!

  • Loading branch information...
commit 147658706108d358d1e9bf34595281e481647d4b 1 parent c041cc5
Evan Phoenix authored May 31, 2011
2  lib/rubygems/commands/sources_command.rb
@@ -77,7 +77,7 @@ def execute
77 77
       rescue URI::Error, ArgumentError
78 78
         say "#{source_uri} is not a URI"
79 79
         terminate_interaction 1
80  
-      rescue Gem::RemoteFetcher::FetchError, Gem::SourceError => e
  80
+      rescue Gem::RemoteFetcher::FetchError => e
81 81
         say "Error fetching #{source_uri}:\n\t#{e.message}"
82 82
         terminate_interaction 1
83 83
       end
17  lib/rubygems/exceptions.rb
@@ -92,20 +92,3 @@ def initialize(exit_code)
92 92
 
93 93
 end
94 94
 
95  
-##
96  
-# An error that indicates there is an error with the source
97  
-# itself (such as the latest_spec file being invalid)
98  
-
99  
-class Gem::SourceError < Gem::Exception
100  
-  def initialize(message, uri)
101  
-    @uri = uri
102  
-    super message
103  
-  end
104  
-
105  
-  attr_reader :uri
106  
-
107  
-  def to_s
108  
-    "#{super} (#{@uri})"
109  
-  end
110  
-end
111  
-
22  lib/rubygems/spec_fetcher.rb
@@ -256,22 +256,12 @@ def load_specs(source_uri, file)
256 256
     local_file = File.join(cache_dir, file_name)
257 257
     retried    = false
258 258
 
259  
-    begin
260  
-      spec_dump = if @update_cache then
261  
-                    FileUtils.mkdir_p cache_dir
262  
-                    @fetcher.cache_update_path(spec_path, local_file)
263  
-                  else
264  
-                    @fetcher.cache_update_path(spec_path)
265  
-                  end
266  
-    rescue Gem::RemoteFetcher::UnknownHostError => e
267  
-      exc = Gem::SourceError.new("Could not contact source", source_uri)
268  
-      exc.source_exception = e
269  
-      raise exc
270  
-    rescue Gem::RemoteFetcher::FetchError => e
271  
-      exc = Gem::SourceError.new("Bad source, unable to get specs", source_uri)
272  
-      exc.source_exception = e
273  
-      raise exc
274  
-    end
  259
+    spec_dump = if @update_cache then
  260
+                  FileUtils.mkdir_p cache_dir
  261
+                  @fetcher.cache_update_path(spec_path, local_file)
  262
+                else
  263
+                  @fetcher.cache_update_path(spec_path)
  264
+                end
275 265
 
276 266
     begin
277 267
       Marshal.load spec_dump
2  test/rubygems/test_gem_commands_sources_command.rb
@@ -90,7 +90,7 @@ def test_execute_add_nonexistent_source
90 90
 
91 91
     expected = <<-EOF
92 92
 Error fetching http://beta-gems.example.com:
93  
-\tBad source, unable to get specs (http://beta-gems.example.com)
  93
+\tit died (#{uri})
94 94
     EOF
95 95
 
96 96
     assert_equal expected, @ui.output

0 notes on commit 1476587

Please sign in to comment.
Something went wrong with that request. Please try again.