VERIFIED SOLUTION i

MapBasic script does not capture the WMS error when the WMS server is not available

Products Affected: Mapinfo Pro™

Issue

Unable to capture WMS error in MapBasic application when WMS is not available

Cause

A WMS server response may be returned after a the MapBasic script has executed an Exit Sub command.

This will result in the MapBasic script failing to report the error despite the server being unavailable.

Resolution

UPDATED: October 20, 2017
Insert an "Update Window Frontwindow() " command right after the run application statement to call the WMS server and you will get the expected message dialog from the error trap.

The should also have a Resume Next statement before the Exit Sub Main statement, otherwise the script will end and not continue to perform other actions after the error is trapped.

You should make the error trap conditional on the error that gets thrown. Otherwise, if an error other than 1807 is thrown, it could have bad consequences.

Here is a simple example: 

_catchErr:
 

if Err() = 1807 then

Note "An appropriate message"
Note Error$()

Else

whatever message you want to display with other errors.

End IF

Resume Next
Exit Sub Main