put some non-ta2 exceptions code behind the right flag
set last thrown exception in rethrow; fixes #2627