Write a python function to call a user-input function with default exception handling and re-raise the exception again.


Topic: Write a python function to call a user-input function with default exception handling and re-raise the exception again.

Solution

def default_exception_simulator(user_func):
    try:
        if callable(user_func):
            user_func()
    except:
        print("An exception occured")
        raise



List all Python Programs