fix status not in the report if headers already sent when an error occurs