Method: Bundler::SharedHelpers#filesystem_access
- Defined in:
- lib/bundler/shared_helpers.rb
permalink #filesystem_access(path, action = :write) { ... } ⇒ Object
Rescues permissions errors raised by file system operations (ie. Errno:EACCESS, Errno::EAGAIN) and raises more friendly errors instead.
104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 |
# File 'lib/bundler/shared_helpers.rb', line 104 def filesystem_access(path, action = :write, &block) yield(path.dup) rescue Errno::EACCES => e raise unless e..include?(path.to_s) || action == :create raise PermissionError.new(path, action) rescue Errno::EAGAIN raise TemporaryResourceError.new(path, action) rescue Errno::EPROTO raise VirtualProtocolError.new rescue Errno::ENOSPC raise NoSpaceOnDeviceError.new(path, action) rescue Errno::ENOTSUP raise OperationNotSupportedError.new(path, action) rescue Errno::EPERM raise OperationNotPermittedError.new(path, action) rescue Errno::EROFS raise ReadOnlyFileSystemError.new(path, action) rescue Errno::EEXIST, Errno::ENOENT raise rescue SystemCallError => e raise GenericSystemCallError.new(e, "There was an error #{[:create, :write].include?(action) ? "creating" : "accessing"} `#{path}`.") end |