Skip to content

Commit

Permalink
switch Listen::Record::SymlinkDetector::Error to use Listen::Error
Browse files Browse the repository at this point in the history
  • Loading branch information
ColinDKelley committed Jan 14, 2021
1 parent 6fa5e2e commit b930860
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 5 deletions.
3 changes: 3 additions & 0 deletions lib/listen/error.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
# frozen_string_literal: true

# Besides programming error exceptions like ArgumentError,
# all public interface exceptions should be declared here and inherit from Listen::Error.
module Listen
class Error < RuntimeError
class NotStarted < Error; end
class SymlinkLoop < Error; end
end
end
2 changes: 1 addition & 1 deletion lib/listen/event/loop.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ module Event
class Loop
include Listen::FSM

class Error < RuntimeError
module Error
NotStarted = ::Listen::Error::NotStarted # for backward compatibility
end

Expand Down
8 changes: 4 additions & 4 deletions lib/listen/record/symlink_detector.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# frozen_string_literal: true

require 'set'
require 'listen/error'

module Listen
# @private api
Expand All @@ -18,23 +19,22 @@ class SymlinkDetector
MORE INFO: #{WIKI}
EOS

class Error < RuntimeError
end
Error = ::Listen::Error # for backward compatibility

def initialize
@real_dirs = Set.new
end

def verify_unwatched!(entry)
real_path = entry.real_path
@real_dirs.add?(real_path) || _fail(entry.sys_path, real_path)
@real_dirs.add?(real_path) or _fail(entry.sys_path, real_path)
end

private

def _fail(symlinked, real_path)
warn(format(SYMLINK_LOOP_ERROR, symlinked, real_path))
raise Error, 'Failed due to looped symlinks'
raise ::Listen::Error::SymlinkLoop, 'Failed due to looped symlinks'
end
end
end
Expand Down

0 comments on commit b930860

Please sign in to comment.