NameError: global name 'HTTPError' is not defined
You probably just need to import the HTTPError
class before using it. Try inserting at the top of your actions.py file:
from urllib2 import HTTPError
and then you should be able to use your code as is.
In Python 3 it's:
from urllib.error import HTTPError
You need to check for urllib2.HTTPError:
except urllib2.HTTPError: