Some more useful error handling for broken services please.

644
1
05-29-2014 09:09 AM
ReneRubalcava
Frequent Contributor
So I ran into this problem with (version 3.9) esri/arcgis/utils#createMap where my defined basemap layer is down, so the map creation errors out completely and breaks my app.

arcgisUtils.createMap(webmapJSON, elementId, options).then(onSuccess, onError);


What I can do is use the error function to add a different basemapLayer url (like the Esri World Imagery), but there are a few issues here.


  • Error seems to delete basemap object from basemapLayers array: This means I have to add a new object instead of just change the URL. It would be cool if you didn't mutate my objects.

  • Error only tells me a URL is not valid: This could mean it's a basemapLayer or maybe an operationalLayer (map fails to create with a bad op layer URL too, checked), I'm not sure how to tell. This makes error handling these kind of things more difficult.

  • Map creation doesn't need to be halted because of a bad URL: A map can exist without a basemap, maybe add the errors to the response callback to check for any errors that occured during the map creation process.

In this case, I can tell after the fact that the basemapLayer is dead, but this doesn't help me in production to handle these errors if I can't tell what has gone wrong. The Error codes do contain an empty details array, so maybe the JS API internals could populate that with some more useful information.

Although I like the idea of not breaking map creation because of a bad URL to begin with. It's much easier to handle a missing layer inside the application than it is to decipher what went wrong in the map creation process.

*edit* - I just double-checked. The response object from the createMap promise does have an errors array. Can you just put any map creation errors there, including invalid URL errors? I suppose I'm confused why a broken basemap/operational URL will halt the map creation process.
1 Reply
JamesKimrey
New Contributor

I agree.  I'm frustrated that I can catch the error and load a backup base map, but I can't keep the original error from propagating, causing the map loading process to halt.

I want to set up a failover process for the base map so that my users will see some type of map underneath my data, instead of just a blank background.

0 Kudos