Implemented _CatchPanic function for handling and logging exceptions