Share via


promise::set_exception Method

Atomically stores an exception as the result of this promise object and sets the associated asynchronous state to ready.

void set_exception(exception_ptr Exc);

Parameters

  • Exc
    An exception_ptr that's stored by this method as the exception result.

Remarks

If the promise object has no associated asynchronous state, this method throws a future_error that has an error code of no_state.

If set_exception, set_exception_at_thread_exit, set_value, or set_value_at_thread_exit has already been called for a promise object that has the same associated asynchronous state, this method throws a future_error that has an error code of promise_already_satisfied.

As a result of this method, any threads that are blocked on the associated asynchronous state become unblocked.

Requirements

Header: future

Namespace: std

See Also

Reference

promise Class

<future>