File size: 663 Bytes
7dce6dc
4c04f50
 
7dce6dc
 
 
 
 
 
 
52a9494
7dce6dc
 
 
 
 
 
 
 
 
 
 
 
52a9494
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
"""Prepare an error message for gradiobee."""
# pylint: disable=invalid-name

from typing import Optional, Tuple, Union
import pandas as pd


def error_msg(
    msg: Optional[Union[str, Exception]],
    title: str = "error message",
) -> Tuple[Union[pd.DataFrame, None], None, None, None, None, None, None, None]:
    """Prepare an error message for gradiobee outputs."""
    if msg is None:
        msg = "none..."

    try:
        msg = msg.__str__()
    except Exception as exc:
        msg = str(exc)

    df = pd.DataFrame([msg], columns=[title])

    # return df, *((None,) * 4)  # pyright complains
    return df, None, None, None, None, None, None, None