<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def set_exception(self, exception, traceback=None):
 """ Sets the exception for this Future in case of errors. :param exception: (Exception), exception to be threw in case of error. :param traceback: (Function), function to be called on traceback (optional). """

        if not isinstance(exception, BaseException):
            raise RuntimeError("Exception must be of BaseException type")
        self._exception = exception
        self._traceback = traceback
        self._event.set()
        self._invoke_callbacks()