Esri/esri-leaflet-vector

Error Handling

gavinr opened this issue · 3 comments

Describe the bug

From @corrigancd in #140:

If a request is unsuccessful (e.g. due to incorrect itemId, hardcoded stylePath, hardcoded baseUrl, portalUrl), the request logs an error to the console, but then the subsequent request to retrieve the vector tile data from the service failed, which crashed our app due to an uncaught error. Then on subsequent browser refreshes, the app continued to crash (as the incorrect parameters are in local storage).

Reproduction

tbd ... I'll try to follow up with this, or @corrigancd are you able to provide reproduction steps?

Logs

No response

System Info

tbd

Additional Information

From @corrigancd in #140:

To get around this, I added an optional parameter to the vectorTileLayer function called errorCallback. This callback function allowed us to handle the error as we usually do in our application;

Proposed code solution: https://github.com/Esri/esri-leaflet-vector/pull/140/files#diff-d87a7a0181c4fb7f5a10b32e3494597f82c320b55306aa848df45d586513b30eR69-R83

Hi @gavinr,

Thanks for getting back on this and I agree it's best to handle them one by one.

For this one, I've made a codepen with an example of needing improved error handling. I added a portalUrl and I've added some characters to the end to make it not valid, but it works if the _INTENTIONALLY_WRONG_PORTAL_URL is removed from the end of the portalUrl. We can see in the console of the screenshot below that an error is logged, but there is currently no way to handle this error (I think) via the usual channel in our application (which crashes our app). For this reason, I think something like an errorCallback property would be useful. Where any errors would be passed from the library to this optional handler function.

Please let me know what you think, I'm happy to give a go at implementing

image

Thanks @corrigancd. We like your idea, but instead of an error callback, we think we should emit an event, (e.g. onErrror). I'll try to work on a PR that does this, or if you want to, PRs are welcome. Thanks!

gavinr commented

Fixed in v4.1.0.