Return a :class:`dict` of errors with keys as the type of error and
        values as a list of errors.

        :returns dict: a dictionary of errors

def to_dict(self):
        '''
        Return a :class:`dict` of errors with keys as the type of error and
        values as a list of errors.

        :returns dict: a dictionary of errors
        '''

        errors = copy.deepcopy(self._errors)
        for key, val in iteritems(self._errors):
            if not len(val):
                errors.pop(key)
        return errors