Return the exception that was set on this future. The exception (or None if no exception was set) is returned only if the future is done. If the future has been cancelled, raises CancelledError. If the future isn't done yet, raises InvalidStateError.
(self)
| 213 | return self._result |
| 214 | |
| 215 | def exception(self): |
| 216 | """Return the exception that was set on this future. |
| 217 | |
| 218 | The exception (or None if no exception was set) is returned only if |
| 219 | the future is done. If the future has been cancelled, raises |
| 220 | CancelledError. If the future isn't done yet, raises |
| 221 | InvalidStateError. |
| 222 | """ |
| 223 | if self._state == _CANCELLED: |
| 224 | raise self._make_cancelled_error() |
| 225 | if self._state != _FINISHED: |
| 226 | raise exceptions.InvalidStateError('Exception is not set.') |
| 227 | self.__log_traceback = False |
| 228 | return self._exception |
| 229 | |
| 230 | def add_done_callback(self, fn, *, context=None): |
| 231 | """Add a callback to be run when the future becomes done. |