'Handle any uncaptured error in the core.
Overrides asyncore\'s handle_error.'

def handle_error(self):

    trace = traceback.format_exc()
    stderr(trace)
    LOGGER.error(u'Fatal    error    in    core,    please    review    exception    log')
    logfile = codecs.open(os.path.join(self.config.core.logdir, u'exceptions.log'), u'a', encoding=u'utf-8')
    logfile.write(u'Fatal    error    in    core,    handle_error()    was    called\n')
    logfile.write((u'last    raw    line    was    %s' % self.raw))
    logfile.write(trace)
    logfile.write(u'Buffer:\n')
    logfile.write(self.buffer)
    logfile.write(u'----------------------------------------\n\n')
    logfile.close()
    if (self.error_count > 10):
        if ((datetime.now() - self.last_error_timestamp).seconds < 5):
            stderr(u"Too    many    errors,    can't    continue")
            os._exit(1)
    self.last_error_timestamp = datetime.now()
    self.error_count = (self.error_count + 1)
