I am loading WMS maps using react-leaflet's WMSTileLayer.
Depending on the layers loaded, the image appears or not.
When the image is not loaded, I have found that Leaflet returns a bunch of tile error's:
Unfortunately I can not find any helpful information in them.
When I send the GetMap query manually (https://wms.geo.admin.ch/?service=WMS&request=GetMap&layers=ch.vbs.armee-kriegsdenkmaeler,ch.swisstopo.hiks-dufour&styles&format=image%2Fpng&transparent=TRUE&version=1.3.0&greyscale=0&width=256&height=256&crs=EPSG%3A3857&bbox=1017529.7205322665,5792092.255337515,1095801.2374962869,5870363.772301538) I get a much more helpful answer:
<ServiceExceptionReport xmlns="http://www.opengis.net/ogc" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" version="1.3.0" xsi:schemaLocation="http://www.opengis.net/ogc http://schemas.opengis.net/wms/1.3.0/exceptions_1_3_0.xsd">
<script/>
<ServiceException> msDrawMap(): Image handling error. Failed to draw layer named 'ch.swisstopo.hiks-dufour'. msShapefileOpen(): Unable to access file. (/var/www/vhosts/wms-bgdi/private/wms-bgdi/ch.swisstopo.hiks-dufour.index) msShapefileOpen(): Unable to access file. (/var/local/geodata/ch.swisstopo.hiks-dufour.index) </ServiceException>
</ServiceExceptionReport>
So I can see that this is a server error because the server is missing a file. And I can also deduce what layer is the culprit.
How can I get this much more helpful error message from Leaflet?
So far I see only one workaround:
- on tileerror, send a GetMap request using fetch
- extract the helpful error from that answer
ch.vbs.armee-kriegsdenkmaeler
andch.swisstopo.hiks-dufour
, it worked for me if I defined them as two separate Leaflet WMS layers.