def _format_exception(exception):
    """Formats the exception into a string."""
    exception_type = type(exception).__name__
    exception_message = str(exception)
    if exception_message:
        return "{}: {}".format(exception_type, exception_message)
    else:
        return exception_type