Flush log first before handling error