From a62053e547279b59fd2ba3bcbe0a84583ecf23b7 Mon Sep 17 00:00:00 2001 From: Eric Wong Date: Wed, 15 Oct 2008 18:06:40 -0700 Subject: [PATCH] Replace the last of the ad-hoc RuntimeError exceptions The ArgumentErrors happen at initialization time, so I'll keep those as-is --- lib/mogilefs.rb | 3 +++ lib/mogilefs/httpfile.rb | 5 ++++- lib/mogilefs/mogilefs.rb | 2 +- 3 files changed, 8 insertions(+), 2 deletions(-) diff --git a/lib/mogilefs.rb b/lib/mogilefs.rb index 6f75461..cbfc5da 100644 --- a/lib/mogilefs.rb +++ b/lib/mogilefs.rb @@ -16,6 +16,9 @@ module MogileFS class ReadOnlyError < Error def message; 'readonly mogilefs'; end end + class EmptyPathError < Error + def message; 'Empty path for mogile upload'; end + end class RequestTruncatedError < Error; end class InvalidResponseError < Error; end diff --git a/lib/mogilefs/httpfile.rb b/lib/mogilefs/httpfile.rb index 7af2d31..0833481 100644 --- a/lib/mogilefs/httpfile.rb +++ b/lib/mogilefs/httpfile.rb @@ -21,6 +21,9 @@ class MogileFS::HTTPFile < StringIO class EmptyResponseError < MogileFS::Error; end class BadResponseError < MogileFS::Error; end class UnparseableResponseError < MogileFS::Error; end + class NoStorageNodesError < MogileFS::Error + def message; 'Unable to open socket to storage node'; end + end ## # The path this file will be stored to. @@ -138,7 +141,7 @@ class MogileFS::HTTPFile < StringIO if @path.nil? then @tried.clear next_path - raise 'Unable to open socket to storage node' if @path.nil? + raise NoStorageNodesError if @path.nil? end @socket = TCPSocket.new @path.host, @path.port diff --git a/lib/mogilefs/mogilefs.rb b/lib/mogilefs/mogilefs.rb index 0a62dba..a07ee27 100644 --- a/lib/mogilefs/mogilefs.rb +++ b/lib/mogilefs/mogilefs.rb @@ -147,7 +147,7 @@ class MogileFS::MogileFS < MogileFS::Client case path when nil, '' then - raise 'Empty path for mogile upload' + raise EmptyPathError when /^http:\/\// then MogileFS::HTTPFile.open(self, res['fid'], path, devid, klass, key, dests, bytes, &block) -- 2.11.4.GIT