PromiseBase::OnError (open)
Schedule functions to run when this promise is rejected
Syntax
LOADLIB "wh::promise.whlib";
OBJECT FUNCTION OnError(FUNCTION PTR onerror)
Parameters
FUNCTION PTR onerror
Function to run when the promise is resolved. Allowed signatures:
- MACRO reject()
- VARIANT FUNCTION reject()
- MACRO reject(OBJECT exception)
- VARIANT FUNCTION reject(OBJECT exception)
If a parameter is present, it will be set to the exception object this promise was rejected with.
If a value is returned, the returned promise is resolved to that value, otherwise the returned promise is
resolved to
DEFAULT RECORD
. If an exception is thrown, the returned exception is rejected with that exception
Return value
OBJECT
A promise that will copy the state of this promise, if this promise is resolved with a value
or the onerror function is a DEFAULT FUNCTION PTR
. If the promise is rejected and the onerror function is set,
the returned promise will be resolved to the value the onerror function returns, or rejected with the exception
the onerror function throws.