Possible errors in telnet

Am writing one script in which it will check whether a device listens on the specific port. using telnet, I have written the script.
Now my doubt is I have to handle different kind of errors that telnet is giving.
Anybody can give the list of errors and what is the cause of that error?
So that I can handle accordingly in my script?

Its appreciable, If you provide any useful URL.

script called with two parameters host and port

#!/usr/bin/expect -f
set timeout 3
set HOST [lindex $argv 0]
set PORT [lindex $argv 1]
#$spawn -noecho $env(SHELL)
spawn -noecho "/bin/bash"
send "telnet ${HOST} ${PORT}\r"
expect {
    "Unknown host"
{
 puts "Unknown Host"
exit 1
}

    "Unable to connect" 
    { 
        puts "not connecting" 
        exit 1
    } 
    "Connected to " 
    {
        send -- "\r"
            expect "telnet>"
            send -- "quit\r"
            expect "Connection closed"
            puts "Connecting "
            exit 0
    }
}
send -- ""
exit 1

@chakrapani,

Thanks for your reply.

But I am not expecting the script.

I want list of possible errors in telnet like

Connection refused - no device to listen on given port.
No route to host - Machine may not be reachable / invalid ip.

some thing like this...