Skip to content

Commit

Permalink
Improved documentation.
Browse files Browse the repository at this point in the history
  • Loading branch information
ioquatix committed Oct 29, 2023
1 parent caeec3b commit 4bde89b
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion lib/async/task.rb
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ def async(*arguments, **options, &block)
return task
end

# Retrieve the current result of the task. Will cause the caller to wait until result is available. If the result was an exception, raise that exception.
# Retrieve the current result of the task. Will cause the caller to wait until result is available. If the task resulted in an unhandled error (derived from `StandardError`), this will be raised. If the task was stopped, this will return `nil`.
#
# Conceptually speaking, waiting on a task should return a result, and if it throws an exception, this is certainly an exceptional case that should represent a failure in your program, not an expected outcome. In other words, you should not design your programs to expect exceptions from `#wait` as a normal flow control, and prefer to catch known exceptions within the task itself and return a result that captures the intention of the failure, e.g. a `TimeoutError` might simply return `nil` or `false` to indicate that the operation did not generate a valid result (as a timeout was an expected outcome of the internal operation in this case).
#
Expand Down

0 comments on commit 4bde89b

Please sign in to comment.