Event listening function to catch global errors and report them back
Event listening function to catch global errors and report them back