'Determine action to take when a download problem appears.
Depending on if the downloader has been configured to ignore
download errors or not, this method may throw an exception or
not when errors are found, after printing the message.
tb, if given, is additional traceback information.'

def trouble(self, message=None, tb=None):

    if (message is not None):
        self.to_stderr(message)
    if self.params.get(u'verbose'):
        if (tb is None):
            if sys.exc_info()[0]:
                tb = u''
                if (hasattr(sys.exc_info()[1], u'exc_info') and sys.exc_info()[1].exc_info[0]):
                    tb += u''.join(traceback.format_exception(*sys.exc_info()[1].exc_info))
                tb += encode_compat_str(traceback.format_exc())
            else:
                tb_data = traceback.format_list(traceback.extract_stack())
                tb = u''.join(tb_data)
        self.to_stderr(tb)
    if (not self.params.get(u'ignoreerrors', False)):
        if (sys.exc_info()[0] and hasattr(sys.exc_info()[1], u'exc_info') and sys.exc_info()[1].exc_info[0]):
            exc_info = sys.exc_info()[1].exc_info
        else:
            exc_info = sys.exc_info()
        raise DownloadError(message, exc_info)
    self._download_retcode = 1
