fixed error flush to correctly produce an error