Separate checks for KeyError from other Exception handling