Commits

Marc-Alexandre Chan committed 6e93c39

Fixed handling for certain HTTP errors; fixed var typo in scheduler _retry_event

Comments (0)

Files changed (2)

minibot/errors.py

 
 # REDDIT
 from praw.errors import *
-from urllib2 import HTTPError
+from urllib2 import HTTPError, URLError
 
 # SQL
-from sqlalchemy.exc import SQLAlchemyError, DBAPIError
+from sqlalchemy.exc import SQLAlchemyError, DBAPIError

minibot/eventscheduler.py

 from minibot.util import classname, log_exc_info
 from minibot.errors import ResourceError, AttachedEventError, InvalidUserPass,\
     LoginRequired, NotLoggedIn, RateLimitExceeded, EventNotFoundError,\
-    HTTPError, MinibotError, SchedulerStoppedError
+    HTTPError, URLError, MinibotError, SchedulerStoppedError
 
 from praw import Reddit
 
             self._retry_event(evtime, priority, status, event)
             return True
 
-        elif isinstance(exc, HTTPError) or\
+        elif isinstance(exc, HTTPError) or isinstance(exc, URLError) or\
                 (isinstance(exc, ValueError) and "No JSON object" in exc):
             # oh, is Reddit having some issues?
             if not hasattr(event, 'delay') or event.delay<self.DELAY_HTTPERROR:
                 u"time=%s, priority=%d, status=%s, event=%s",
                 classname(self),
                 time.strftime('%Y-%m-%d %H:%M:%S', time.localtime(r_time)),
-                r_priority, self.STATUS_STRING[r_status], unicode(event))
+                r_priority, self.STATUS_STRING[status], unicode(event))
         else:
             self.logger.debug(
                 u"%s: Queued retry: "
                 u"time=%s, priority=%d, status=%s, event=%s",
                 classname(self),
                 time.strftime('%Y-%m-%d %H:%M:%S', time.localtime(r_time)),
-                r_priority, self.STATUS_STRING[r_status], unicode(event))
+                r_priority, self.STATUS_STRING[status], unicode(event))
         event.delay = None
 
     def prepare_event(self, event):