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

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

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

StringGrid issue in Delphi XE8 firemonkey mobile app -