catch errors in _flush