[#1725] Fix exception caught when there's no CKAN_CURRENT_URL

When we try to get a key from a dict and it doesn't exist, a KeyError is
raised, not a TypeError.