python - raise ConnectionError in python2.7 -


i want raise connectionerror (a python 3 subclass) when program fails connect local service. i'm using python2.7. testing out though, looks have import module working:

>>> raise connectionerror("test") traceback (most recent call last):   file "<stdin>", line 1, in <module> nameerror: name 'connectionerror' not defined 

how can raise type of exception?

connectionerror not exist in python 2, can see the python 2 documentation. can of course create own subclass of oserror (and call connectionerror if want), no such thing built in.


Comments

Popular posts from this blog

android - Gradle sync Error:Configuration with name 'default' not found -

java - Andrioid studio start fail: Fatal error initializing 'null' -

html - jQuery UI Sortable - Remove placeholder after item is dropped -