Jump to content

Reporting Error Message


 Share

Recommended Posts

I'm listing the error message strings, and roughly matching the error code

Is this how to do error reporting?  Is there a more simple way I don't know about?

I realise I might not need to trap @error inside $error.  I like it this way b/c I have no fear of overwriting @error now; I don't even use it.

Func Send_Connect($address, $port)
    $socket = TCPConnect($address, $port)
    $error = @error
    If $error <> 0 Then
        Local $aError[4] = ["-2 not connected.", _
                            "1 IPAddr is incorrect.", _
                            "2 port is incorrect."]
        $aError[3] = "10060 Connection timed out."
        If $error < 0 Then $error = 0
        If $error > 2 Then $error = 3
        MsgBox(0, "TCP Connect Error", $aError[$error], 0)
        $socket = 0
    EndIf
    Return $socket
EndFunc
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...