Replace KeyError by dedicated exception