Make KeyError from 'get_metadata' more flexible.

Allow subclasses to define a `CUSTOM_METADATA_FIELDS` mapping which
maps field name -> accessor name, and use it to generate more meaningful
error message when raising KeyError for those fields.