(f)
return inner
Safely call an object without causing errors
Safely call an object without causing errors
Safely call an object without causing errors
def safe(f):
    """
    Safely call an object without causing errors
    """
    def inner(*args, **kwargs):
        try:
            return f(*args, **kwargs)
        except Exception as exc:
            logger.error(f"Error with {f.__name__}: {exc}")
            text = kwargs.get('text', args[0])
            return text

    return inner
def safe ( f ) : def inner ( * args , * * kwargs ) : try : return f ( * args , * * kwargs ) except Exception as exc : logger . error ( f"Error with {f.__name__}: {exc}" ) text = kwargs . get ( 'text' , args [ 0 ] ) return text return inner