async icon indicating copy to clipboard operation
async copied to clipboard

Docs: Task#result does not re-raise exceptions

Open emiltin opened this issue 3 years ago • 1 comments

The 'Exceptions' section of the documentation: https://socketry.github.io/async/guides/getting-started/index.html#exception-handling

Includes the code:

require 'async'

task = Async do
	# Exception will be logged and task will be failed.
	raise "Boom"
end

puts task.status # failed
puts task.result # raises RuntimeError: Boom

Which indicates that task.resultwill re-raise the expection. But actually it just outputs "Boom". It only re-raises if Task#wait is used.

emiltin avatar Feb 11 '22 14:02 emiltin

Ah yes.

I've been reworking the interface slightly.

  • Task#result does not block and just returns whatever (nil if the task is still running).
  • Task#wait waits and returns the result of the task.

I think we should make this clear in the documentation if it's not already.

ioquatix avatar Feb 12 '22 22:02 ioquatix