vendor/systemu.rb in pasv_lib-0.1.2 vs vendor/systemu.rb in pasv_lib-0.2.0

- old
+ new

@@ -46,10 +46,13 @@ # error class # class Error < RuntimeError end + class Eexist < Error + end + # # constants # SystemUniversal::VERSION = '2.6.5' unless SystemUniversal.send(:const_defined?, :VERSION) def SystemUniversal.version() SystemUniversal::VERSION end @@ -126,14 +129,23 @@ else begin buf = pipe.read buf = "#{ line }#{ buf }" e = Marshal.load buf - raise unless Exception === e - raise e + + # If Marshal load loaded a particular exception, raise it. + if Exception === e + raise e + else + raise + end + + # regardless of the error raised, we want to raise SystemUniversal::Error so we have one thnig to catch. + rescue e + raise Error, "systemu: Error - process interrupted (original error: #{e.inspect})!\n#{ buf }\n" rescue - raise Error "systemu: Error - process interrupted!\n#{ buf }\n" + raise Error, "systemu: Error - process interrupted!\n#{ buf }\n" end end thread = new_thread cid, @block if @block pipe.read rescue nil end @@ -278,11 +290,11 @@ tmp = File.join(d, slug_for("systemu_#{ @host }_#{ @ppid }_#{ @pid }_#{ rand }_#{ i += 1 }")) begin Dir.mkdir tmp - rescue Errno::EEXIST - raise Error if i >= max + rescue Errno::EEXIST => e + raise Eexist, e.message if i >= max next end break( if b