Fixed bug with flush log before throw