leaflet-geosearch icon indicating copy to clipboard operation
leaflet-geosearch copied to clipboard

Add support for fallback providers

Open nikolauskrismer opened this issue 6 years ago • 6 comments

Just had the issue that nominatim was not reachable.

I was wondering if it is possible to catch such errors and fallback to other providers in that case (or to catch the error and show some message)

I did not find anything that would relate to such problems in the code, but maybe I am missing something... if so, I guess it would be a good idea to add a small sample to the docs :-)

nikolauskrismer avatar Aug 02 '18 18:08 nikolauskrismer

HI @nikolauskrismer , thanks for opening this issue. Please may I know how you solved this issue? I'm currently experiencing a similar error with nominatim. Thanks

jeafreezy avatar Oct 27 '20 20:10 jeafreezy

@jeafreezy To be honest, I don't think that original issue will be the same as yours. Just describe your problem here a bit wider. Providing demo (like JSFiddle) will be awesome.

@smeijer I think "Providers fallback" will be good title for this issue, don’t you think? Also, it maybe related to issue https://github.com/smeijer/leaflet-geosearch/issues/153 (in both case we are manipulating with multiple providers)

yznts avatar Oct 28 '20 07:10 yznts

Yeah, I think this "error handling" should be solved by wrapping one or more providers. See also https://github.com/smeijer/leaflet-geosearch/issues/153#issuecomment-348686251.

The docs have an example on how to use a single provider directly. That one should be extended with searching in the fallback provider, if the first doesn't have results.

https://smeijer.github.io/leaflet-geosearch/usage#using-the-providers-directly

That being said, I doubt that provider 2 will have results, when provider 1 doesn't. Thereby, I don't really feel for adding native support for that.

I'm willing to reconsider if someone can come up with concrete examples of "x has no results for ..., but provider y has".

smeijer avatar Oct 28 '20 08:10 smeijer

Thank you @yuriizinets for the swift response. Unfortunately, I didn't take a screenshot of the error, but the error code was 400. My search box was making a request using the OpenStreetMaps provider and at that time the server was returning an error code. It's working fine now but my concern is that this should not happen in production and if at all it does, is there away I can catch such an error so I can display to the users some text e.g "THe server is down at the moment,kindly check back later" . Thanks

jeafreezy avatar Oct 28 '20 09:10 jeafreezy

We currently don't have a handler for those kind of errors. That's something that should definitely be added. I've created #245 to cover that change.

smeijer avatar Oct 28 '20 10:10 smeijer

Thank you @smeijer !

jeafreezy avatar Oct 28 '20 13:10 jeafreezy