Fix handling of errors

Revert to previous state after exiting handler
Port warning reporting to the "catch" pattern