lib/socketry/timeout.rb in socketry-0.2.0 vs lib/socketry/timeout.rb in socketry-0.3.0
- old
+ new
@@ -42,9 +42,11 @@
# @return [Float] deadline (relative to #lifetime) at which the timeout is reached
# @raise [Socketry::InternalError] if timeout is already set
def set_timeout(timeout)
raise Socketry::InternalError, "deadline already set" if @deadline
return unless timeout
+ raise Socketry::TimeoutError, "time expired" if timeout < 0
+
@deadline = lifetime + timeout
end
# Clear an already-set timeout
#