class CustomError(Exception): def __init__(self, msg): self.msg = msg def stringify_subst(subst): if isinstance(subst, str): return subst elements = [f"{key}: {str(value)}" for key, value in subst.items()] return "{" + ', '.join(elements) + "}"