def exception_msgmaker()

in src/es_pii_tool/helpers/utils.py [0:0]


def exception_msgmaker(exc: t.Union[e.MissingIndex, e.BadClientResult]) -> str:
    """Most of the messages here are similar enough to warrant a single function"""
    msg = ''
    upstream = (
        f'The upstream exception type was {type(exc.upstream).__name__}, '
        f'with error message: {exc.upstream.args[0]}'
    )
    if isinstance(exc, e.MissingIndex):
        msg = (
            f'Exception raised because index {exc.missing} was not found. '
            f'{upstream}'
        )
    elif isinstance(exc, e.BadClientResult):
        msg = (
            f'Exception raised because of a bad or unexpected response or result '
            f'from the Elasticsearch cluster. {upstream}'
        )
    return msg