AnsweredAssumed Answered

How do I catch an image server's exportImage error using the JS API?

Question asked by choward_blueraster on Jun 26, 2020
Latest reply on Jun 30, 2020 by choward_blueraster

I'm using the 4.X JS API to create client side raster functions for various image services and adding them to the imagery layer's renderingRule property. When I set these raster functions as a renderingRule, an image is usually returned to me as a success. In some cases, I will get an "Unable to load.." error message in my console. I would like to catch this error and use it in my code (display error message, stop loader, etc). However, most methods that I could think of haven't worked out. I've tried the following methods to catch the error:

  • using an AfterInterceptor
  • watching the loaded property on the imagery layer
  • watching the loadError property on the imagery layer
  • try/catch when adding the layer/applying the rule
  • on('layerview-error') event listener
  • layer.when

 

My suspicion is that the layer "loads" fine with a valid url, so none of these are "failing" because the only failed part is an invalid renderingRule that was sent to the server.

 

I've created a codepen sample with the bug in place. Open the console and toggle the select to use "GNDVI". Additionally, I've attached a screenshot of the error from my console.

 

Any help or insight would be appreciated!

Outcomes