Skip to content

Commit

Permalink
Capture potential NameError exception in asked_for_progress? method
Browse files Browse the repository at this point in the history
A known bug in JRuby would cause aquatone to error out because the
IO::EAGAINWaitReadable constant has not been defined.

Capture this potential exception and return false to prevent aquatone
from crashing.
  • Loading branch information
Michael Henriksen committed Jun 24, 2017
1 parent 68a8526 commit 3d85181
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 7 deletions.
4 changes: 3 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
### Added

### Changed
- Capture potential `NameError` exception in `asked_for_progress?` method,
related to known JRuby bug (issue #4)

## [0.1.1]
### Added
Expand All @@ -22,5 +24,5 @@ and this project adheres to [Semantic Versioning](http://semver.org/).

### Changed

[Unreleased]: https://github.com/michenriksen/aquatone/compare/v0.1.0...HEAD
[Unreleased]: https://github.com/michenriksen/aquatone/compare/v0.1.1...HEAD
[0.1.1]: https://github.com/michenriksen/aquatone/compare/v0.1.0...v0.1.1
16 changes: 10 additions & 6 deletions lib/aquatone/command.rb
Original file line number Diff line number Diff line change
Expand Up @@ -112,14 +112,18 @@ def seconds_to_time(seconds)
end

def asked_for_progress?
while c = STDIN.read_nonblock(1)
return true if c == "\n"
begin
while c = STDIN.read_nonblock(1)
return true if c == "\n"
end
false
rescue IO::EAGAINWaitReadable
false
rescue Errno::EINTR, Errno::EAGAIN, EOFError
true
end
rescue NameError
false
rescue IO::EAGAINWaitReadable
false
rescue Errno::EINTR, Errno::EAGAIN, EOFError
true
end

def has_executable?(name)
Expand Down

0 comments on commit 3d85181

Please sign in to comment.