Added general error functionality in beforeGlobal.