+ def trouble(self, message=None):
+ """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. If it
+ doesn't raise, it returns an error code suitable to be returned
+ later as a program exit code to indicate error.
+ """
+ if message is not None:
+ self.to_stderr(message)
+ if not self._params.get('ignoreerrors', False):
+ raise DownloadError(message)
+ return 1
+