Exception handling for the function call