Bug fix:
Because we're using js interop, if an asyn call returns a dictionary - this will get converted to a javascript object and will then be returned as a proxy object.
We don't want that so instead wrap the return value in a more opaque python class that won't be subject to the same javascript <-> python dance.
Changes:
Raise a RuntimeError if trying to access the result/error from a promise before it has fulfilled.
Trying to use the result property before the function has returned is a recipe for disaster.
We're not Javascript so we should raise an exception.
Use anvil.js.report_exceptions to wrap the error/result handlers.
Currently if the result_handler raises an exception this exception would get passed to the on_error handler.
We don't want that. The on_error handler should be exclusively for errors thrown by the function that was called asynchronously.
Bug fix: Because we're using js interop, if an asyn call returns a dictionary - this will get converted to a javascript object and will then be returned as a proxy object. We don't want that so instead wrap the return value in a more opaque python class that won't be subject to the same javascript <-> python dance.
Changes: Raise a RuntimeError if trying to access the result/error from a promise before it has fulfilled. Trying to use the result property before the function has returned is a recipe for disaster. We're not Javascript so we should raise an exception.
Use
anvil.js.report_exceptions
to wrap the error/result handlers. Currently if theresult_handler
raises an exception this exception would get passed to theon_error
handler. We don't want that. Theon_error
handler should be exclusively for errors thrown by the function that was called asynchronously.