fix error scoping in catch blocks