Q:

Adding exceptions for not recognized error? 

I get this error:
  File "/usr/lib/python2.7/dist-packages/paramiko/client.py", line 286, in connect
    for (family, socktype, proto, canonname, sockaddr) in socket.getaddrinfo(hostname, port, socket. AF_UNSPEC, socket. SOCK_STREAM):
gaierror: [Errno -2] Name or service not known

When I enter wrong hostname.  I want to put an exception, giving message that wrong hostname was entered, but Python does not recognize that error and I get global name gaierror not defined. 
I was trying like this:
try:
    ssh.connect(rec.host, username=rec.user, password=rec.password)
except gaierror:
    print 'blablabla'

Then it gives this error:
    except gaierror:
NameError: global name 'gaierror' is not defined

Do I need to define that error myself somehow or I need to call something from paramiko, so python would understand that exception? 

A:

Import the gaierror exception from the socket module.  Docs
import socket

try:
    # Your code. 
except socket.gaierror:
    # Handle exception.