def _get_trailing_metadata_from_interceptor_exception(exception):
    """Retrieves trailing metadata from an exception object.

    Args:
        exception: an instance of grpc.Call.

    Returns:
        A tuple of trailing metadata key value pairs.
    """
    try:
        # GoogleAdsFailure exceptions will contain trailing metadata on the
        # error attribute.
        return exception.error.trailing_metadata()
    except AttributeError:
        try:
            # Transport failures, i.e. issues at the gRPC layer, will contain
            # trailing metadata on the exception iself.
            return exception.trailing_metadata()
        except AttributeError:
            # if trailing metadata is not found in either location then
            # return an empty tuple
            return tuple()