<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def _handle_exception(self, exc):
 """Common exception handling behavior across all exceptions. .. note:: This for internal use and should not be extended or used directly. """

        exc_info = sys.exc_info()
        self.logger.exception(
            '%s while processing message #%s',
            exc.__class__.__name__, self._message.delivery_tag,
            exc_info=exc_info)
        self._measurement.set_tag('exception', exc.__class__.__name__)
        if hasattr(exc, 'metric') and exc.metric:
            self._measurement.set_tag('error', exc.metric)
        self._process.send_exception_to_sentry(exc_info)
        self._maybe_clear_confirmation_futures()
        if not self._finished:
            self.on_finish(exc)
        self._finished = True