Validation/Error handling of WMS

Hi Guys,

How to handle the error in wms when the wms path is not valid.

I have used errorEvent but not able to handle error.

Sample code from sandcastle:

var viewer = new Cesium.Viewer(‘cesiumContainer’);

// Add an ArcGIS MapServer imagery layer

var imageryLayers = viewer.imageryLayers;

imageryLayers.addImageryProvider(new Cesium.ArcGisMapServerImageryProvider({

url : ‘https://nationalmap.gov.au/proxy/http://services.ga.gov.au/site_3/rest/services/Electricity_Infrastructure/MapServer

}));

// Start off looking at Australia.

viewer.camera.setView({

destination: Cesium.Rectangle.fromDegrees(114.591, -45.837, 148.970, -5.730)

});

**Incase if the url path is invalid… How can i handle error… **

Is their any way to handle it…

Do you mean if the URL itself you’re passing to the imagery provider isn’t valid? If so, you can just use the provider’s readyPromise:

https://cesiumjs.org/Cesium/Build/Documentation/ArcGisMapServerImageryProvider.html#readyPromise

Here’s an example with a URL that isn’t valid to show you how to listen for the success/fail events.

var viewer = new Cesium.Viewer(‘cesiumContainer’);

// Add an ArcGIS MapServer imagery layer

var imageryLayers = viewer.imageryLayers;

var provider = new Cesium.ArcGisMapServerImageryProvider({

url : ‘123’

});

provider.readyPromise.then(function(){

console.log(“Success!”);

}).otherwise(function(error){

console.log(“Fail”, error);

});

imageryLayers.addImageryProvider(provider);

``