summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThe Bundler Bot <bot@bundler.io>2016-12-14 22:16:32 +0000
committerThe Bundler Bot <bot@bundler.io>2016-12-14 22:16:32 +0000
commitbbdedac87996d869e2fa70f1f9f702e8f1195328 (patch)
tree987891a5fe5455bb898cf902a77311e9a6a7b9cf
parentaa246fb680c8ef19ca315133fc4d51668fd67ab6 (diff)
parente81161c744242580c14854a7ec4563383bf07db5 (diff)
downloadbundler-bbdedac87996d869e2fa70f1f9f702e8f1195328.tar.gz
Auto merge of #5219 - bundler:seg-filesystem-access-generic-system-error, r=indirect
[SharedHelpers] Handle generic SystemCallErrors in #filesystem_access Closes #5134
-rw-r--r--lib/bundler/errors.rb20
-rw-r--r--lib/bundler/shared_helpers.rb6
-rw-r--r--spec/bundler/shared_helpers_spec.rb21
3 files changed, 47 insertions, 0 deletions
diff --git a/lib/bundler/errors.rb b/lib/bundler/errors.rb
index dd5782fb3d..be72a9ee47 100644
--- a/lib/bundler/errors.rb
+++ b/lib/bundler/errors.rb
@@ -132,4 +132,24 @@ module Bundler
status_code(28)
end
+
+ class NoSpaceOnDeviceError < PermissionError
+ def message
+ "There was an error while trying to #{action} `#{@path}`. " \
+ "There was insufficent space remaining on the device."
+ end
+
+ status_code(31)
+ end
+
+ class GenericSystemCallError < BundlerError
+ attr_reader :underlying_error
+
+ def initialize(underlying_error, message)
+ @underlying_error = underlying_error
+ super("#{message}\nThe underlying system error is #{@underlying_error.class}: #{@underlying_error}")
+ end
+
+ status_code(32)
+ end
end
diff --git a/lib/bundler/shared_helpers.rb b/lib/bundler/shared_helpers.rb
index 0ddcea1ca5..62ade29e30 100644
--- a/lib/bundler/shared_helpers.rb
+++ b/lib/bundler/shared_helpers.rb
@@ -111,8 +111,14 @@ module Bundler
raise TemporaryResourceError.new(path, action)
rescue Errno::EPROTO
raise VirtualProtocolError.new
+ rescue Errno::ENOSPC
+ raise NoSpaceOnDeviceError.new(path, action)
rescue *[const_get_safely(:ENOTSUP, Errno)].compact
raise OperationNotSupportedError.new(path, action)
+ rescue Errno::EEXIST, Errno::ENOENT
+ raise
+ rescue SystemCallError => e
+ raise GenericSystemCallError.new(e, "There was an error accessing `#{path}`.")
end
def const_get_safely(constant_name, namespace)
diff --git a/spec/bundler/shared_helpers_spec.rb b/spec/bundler/shared_helpers_spec.rb
index 8826dcd4dd..fc3371acfb 100644
--- a/spec/bundler/shared_helpers_spec.rb
+++ b/spec/bundler/shared_helpers_spec.rb
@@ -388,6 +388,27 @@ describe Bundler::SharedHelpers do
)
end
end
+
+ context "system throws Errno::ENOSPC" do
+ let(:file_op_block) { proc {|_path| raise Errno::ENOSPC } }
+
+ it "raises a NoSpaceOnDeviceError" do
+ expect { subject.filesystem_access("/path", &file_op_block) }.to raise_error(
+ Bundler::NoSpaceOnDeviceError
+ )
+ end
+ end
+
+ context "system throws an unhandled SystemCallError" do
+ let(:error) { SystemCallError.new("Shields down", 1337) }
+ let(:file_op_block) { proc {|_path| raise error } }
+
+ it "raises a GenericSystemCallError" do
+ expect { subject.filesystem_access("/path", &file_op_block) }.to raise_error(
+ Bundler::GenericSystemCallError, /error accessing.+underlying.+Shields down/m
+ )
+ end
+ end
end
describe "#const_get_safely" do