<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def get_fields_for_exception(self, logger, exception):
 """ Given an exception instance, return fields to add to the failed action message. @param logger: ``ILogger`` currently being used. @param exception: An exception instance. @return: Dictionary with fields to include. """

        for klass in getmro(exception.__class__):
            if klass in self.registry:
                extractor = self.registry[klass]
                try:
                    return extractor(exception)
                except:
                    from ._traceback import write_traceback
                    write_traceback(logger)
                    return {}
        return {}