async
async copied to clipboard
Docs: Task#result does not re-raise exceptions
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.
Ah yes.
I've been reworking the interface slightly.
Task#resultdoes not block and just returns whatever (nil if the task is still running).Task#waitwaits and returns the result of the task.
I think we should make this clear in the documentation if it's not already.