How to catch invalid token errors while map is running in browser?

07-02-2020 06:12 PM
New Contributor II

How can I catch errors while the map is running in a browser?

For example, I have this code:

 ], function(WebMap, MapView) {

webmap = new WebMap({
 portalItem: {
 id: "000000000000000000000000000000"

view = new MapView({
 container: "viewDiv",
 map: webmap

Everything works fine, but if I don't renew the token in time, or something happens to invalidate the token before it is time to be regenerated, I would get an error like this:

dojo-lite.js:261 [esri.views.2d.layers.features.controllers.OnDemandController]

  1. {name: "featurelayer-controller:tile-error", message: "Encountered an error when handling tile response", details: {…}}
    1. details: {name: "request:server", message: "Invalid token.", details: {…}}
    2. message: "Encountered an error when handling tile response"
    3. name: "featurelayer-controller:tile-error"

How can I catch that with JavaScript?  If I can catch it, I can generate a new token and handle it properly.

0 Kudos
1 Reply
New Contributor

We are experiencing the same issue. If we keep map open and with no interaction for some hour, we get same errors and page (map) needs to be refreshed. Do we have a solution for this? Can we catch somewhere this error?

view.when(() => {}, (err) => { // handle err });

does not catch anything. Do we have an update on this?

Thank you

0 Kudos