Skip to content

Commit

Permalink
Add more context to timeout error
Browse files Browse the repository at this point in the history
  • Loading branch information
mperham committed Sep 15, 2022
1 parent a105ff6 commit ac46d5d
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion lib/connection_pool/timed_stack.rb
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ def pop(timeout = 0.5, options = {})
return connection if connection

to_wait = deadline - current_time
raise ConnectionPool::TimeoutError, "Waited #{timeout} sec" if to_wait <= 0
raise ConnectionPool::TimeoutError, "Waited #{timeout} sec, #{length}/#{@max} available" if to_wait <= 0
@resource.wait(@mutex, to_wait)
end
end
Expand Down
4 changes: 2 additions & 2 deletions test/test_connection_pool_timed_stack.rb
Original file line number Diff line number Diff line change
Expand Up @@ -63,12 +63,12 @@ def test_pop

def test_pop_empty
e = assert_raises(ConnectionPool::TimeoutError) { @stack.pop timeout: 0 }
assert_equal "Waited 0 sec", e.message
assert_equal "Waited 0 sec, 0/0 available", e.message
end

def test_pop_empty_2_0_compatibility
e = assert_raises(Timeout::Error) { @stack.pop 0 }
assert_equal "Waited 0 sec", e.message
assert_equal "Waited 0 sec, 0/0 available", e.message
end

def test_pop_full
Expand Down

0 comments on commit ac46d5d

Please sign in to comment.