Catch KeyError in smaller scope.