CheckServerConnection: unable to trap some errors

I want to stop a procedure that adds a record if the server is not connected and then do other things: trying to reconnect and if that fails, telling the user to contact me. Since I am using a VPN to connect to the server network, I can easily turn it on and off in order to test my code. Here is the code I have tried:

checkserverconnection "SD PanX Server"
if error
    console "Sorry, server is not connected."
    //[More code...]
else
    console "server ok"  
endif

With the VPN connected, I get the console message ‘server ok’. But if I disconnect the VPN connection then run the code, I get the default error dialog after the timeout period (set for 20 seconds) for trying to make a connection and the procedure stops.

Looks like ‘if error’ did not trap the error. But also, if I insert a server that does not exist, the error is trapped immediately and I get my console message.

I am going to try to use try/catch to see if that works.

With no VPN connection, and hence no server server connection, this code does NOT run the catch block!

try
    connecttoserver
catch
    console "did not connect to server"
endcatch

Looks like the connecttoserver is not returning an error if the attempt to connect to a server fails.

I fixed the connecttoserver statement so that it generates a catchable error if the connection fails.

The checkserverconnection statement was a bit trickier. Instead of fixing it as is, I decided to change it so that it returns a true/false result in a parameter instead of generating an error. I also created a checkserverconnection( function which is now probably the easiest way to use it.

if checkserverconnection("My Server")=false()
    oh no!!
endif

Since I was working with the lock/unlock code, I went ahead and added the auto-server unlock code I mentioned before (which I said I would not put in the next beta). So now if the client/server connection is broken for more than a specified length of time (for example shutting the lid, a broken network, or a crash), the server will automatically unlock the record if another user asks to edit it (but only after a configurable “safe” time has passed).

So my plan is to fix a few more items off the BitBucket list, then write up change notes for all the changes in b11 (the documentation is already written, just need change notes), and then get it into your hands! Also, I heard something about a holiday coming up, I may need to look into that also. Stay safe!