+ 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 exit the program or
+ not when errors are found, after printing the message. If it
+ doesn't exit, 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):
+ sys.exit(1)
+ return 1
+