Skip to content
Snippets Groups Projects
Commit 4fd78c96 authored by Jack Nagel's avatar Jack Nagel
Browse files

Provide more information about link errors

References Homebrew/homebrew#32046.
parent 0d154a99
No related branches found
No related tags found
No related merge requests found
......@@ -16,10 +16,13 @@ class Keg
class LinkError < RuntimeError
attr_reader :keg, :src, :dst
def initialize(keg, src, dst)
def initialize(keg, src, dst, cause)
@src = src
@dst = dst
@keg = keg
@cause = cause
super(cause.message)
set_backtrace(cause.backtrace)
end
end
......@@ -361,17 +364,17 @@ class Keg
dst.delete if mode.overwrite && (dst.exist? || dst.symlink?)
dst.make_relative_symlink(src)
rescue Errno::EEXIST
rescue Errno::EEXIST => e
if dst.exist?
raise ConflictError.new(self, src.relative_path_from(path), dst)
raise ConflictError.new(self, src.relative_path_from(path), dst, e)
elsif dst.symlink?
dst.unlink
retry
end
rescue Errno::EACCES
raise DirectoryNotWritableError.new(self, src.relative_path_from(path), dst)
rescue SystemCallError
raise LinkError.new(self, src.relative_path_from(path), dst)
rescue Errno::EACCES => e
raise DirectoryNotWritableError.new(self, src.relative_path_from(path), dst, e)
rescue SystemCallError => e
raise LinkError.new(self, src.relative_path_from(path), dst, e)
end
protected
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment