<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Catch a failure to load map when an exception isn't being thrown in ArcGIS JavaScript Maps SDK Questions</title>
    <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/catch-a-failure-to-load-map-when-an-exception-isn/m-p/480360#M44685</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;maybe tie into the &lt;/SPAN&gt;&lt;STRONG&gt;onLoad&lt;/STRONG&gt;&lt;SPAN&gt; and/or &lt;/SPAN&gt;&lt;STRONG&gt;onError &lt;/STRONG&gt;&lt;SPAN&gt;events of the Layer rather than the events of the map?&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Tue, 29 Jun 2010 12:10:37 GMT</pubDate>
    <dc:creator>AdamPfister</dc:creator>
    <dc:date>2010-06-29T12:10:37Z</dc:date>
    <item>
      <title>Catch a failure to load map when an exception isn't being thrown</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/catch-a-failure-to-load-map-when-an-exception-isn/m-p/480356#M44681</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;I have code that looks something like this:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; map = new esri.Map("mapDiv");&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; dojo.connect(map, "onLoad", DoSomething);&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; map.addLayer(service);&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;If for some reason the service isn't being added, then the OnLoad event doesn't happen and DoSomething doesn't get called.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;If the map fails to load, I would like to report back to the user so the user knows there is a problem and doesn't waif for DoSomething.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Is there a way to catch this and handle it gracefully - note that the addLayer method call is not throwing an exception.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Thank you in advance.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;TJ&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 15 Jun 2010 15:02:01 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/catch-a-failure-to-load-map-when-an-exception-isn/m-p/480356#M44681</guid>
      <dc:creator>TJBara</dc:creator>
      <dc:date>2010-06-15T15:02:01Z</dc:date>
    </item>
    <item>
      <title>Re: Catch a failure to load map when an exception isn't being thrown</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/catch-a-failure-to-load-map-when-an-exception-isn/m-p/480357#M44682</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Take a look at the description of the 'onLoad' event from the documentation (&lt;/SPAN&gt;&lt;A href="http://help.arcgis.com/en/webapi/javascript/arcgis/help/jsapi/map.htm#onLoad):" rel="nofollow noopener noreferrer" target="_blank"&gt;http://help.arcgis.com/en/webapi/javascript/arcgis/help/jsapi/map.htm#onLoad):&lt;/A&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BLOCKQUOTE class="jive-quote"&gt;Fires when the first or base layer has been successfully added to the map.&lt;/BLOCKQUOTE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;It looks like it won't fire until you add your first layer to the map.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;If you want to catch errors look at the 'onLayerAddResult' event (&lt;/SPAN&gt;&lt;A href="http://help.arcgis.com/en/webapi/javascript/arcgis/help/jsapi/map.htm#onLayersAddResult):" rel="nofollow noopener noreferrer" target="_blank"&gt;http://help.arcgis.com/en/webapi/javascript/arcgis/help/jsapi/map.htm#onLayersAddResult):&lt;/A&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;onLayerAddResult(layer, error)&amp;nbsp; Fires after specified layer has been added to the map.&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;in that event you can look for an error.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;or maybe you can wrap the map initialization in a try/catch block?&lt;/SPAN&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;
try {
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; map = new esri.Map()...
} catch (e) {
&amp;nbsp;&amp;nbsp;&amp;nbsp; //get error message
}
&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 21:12:07 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/catch-a-failure-to-load-map-when-an-exception-isn/m-p/480357#M44682</guid>
      <dc:creator>AdamPfister</dc:creator>
      <dc:date>2021-12-11T21:12:07Z</dc:date>
    </item>
    <item>
      <title>Re: Catch a failure to load map when an exception isn't being thrown</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/catch-a-failure-to-load-map-when-an-exception-isn/m-p/480358#M44683</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;The "stipulation" of successfully loading the base layer onto a map you reference before OnLoad fires is actually the issue I was describing.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;It wasn't throwing an error I could catch in a try/catch block.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I will look into the OnLayerAddResult event.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Thank you.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 23 Jun 2010 14:25:09 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/catch-a-failure-to-load-map-when-an-exception-isn/m-p/480358#M44683</guid>
      <dc:creator>TJBara</dc:creator>
      <dc:date>2010-06-23T14:25:09Z</dc:date>
    </item>
    <item>
      <title>Re: Catch a failure to load map when an exception isn't being thrown</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/catch-a-failure-to-load-map-when-an-exception-isn/m-p/480359#M44684</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;BLOCKQUOTE class="jive-quote"&gt;The "stipulation" of successfully loading the base layer onto a map you reference before OnLoad fires is actually the issue I was describing.&lt;BR /&gt;&lt;BR /&gt;It wasn't throwing an error I could catch in a try/catch block.&lt;BR /&gt;&lt;BR /&gt;I will look into the OnLayerAddResult event.&lt;BR /&gt;&lt;BR /&gt;Thank you.&lt;/BLOCKQUOTE&gt;&lt;BR /&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;It looks like the OnLayerAddResult is part of the Beta 2.0 Javascript API.&amp;nbsp; We are using 1.6, so it is not possible to assess this would be useful int the future.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;So the question for me remains is there way to catch the fact that the map did not successfully add a layer.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;TJ&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 25 Jun 2010 17:01:26 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/catch-a-failure-to-load-map-when-an-exception-isn/m-p/480359#M44684</guid>
      <dc:creator>TJBara</dc:creator>
      <dc:date>2010-06-25T17:01:26Z</dc:date>
    </item>
    <item>
      <title>Re: Catch a failure to load map when an exception isn't being thrown</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/catch-a-failure-to-load-map-when-an-exception-isn/m-p/480360#M44685</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;maybe tie into the &lt;/SPAN&gt;&lt;STRONG&gt;onLoad&lt;/STRONG&gt;&lt;SPAN&gt; and/or &lt;/SPAN&gt;&lt;STRONG&gt;onError &lt;/STRONG&gt;&lt;SPAN&gt;events of the Layer rather than the events of the map?&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 29 Jun 2010 12:10:37 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/catch-a-failure-to-load-map-when-an-exception-isn/m-p/480360#M44685</guid>
      <dc:creator>AdamPfister</dc:creator>
      <dc:date>2010-06-29T12:10:37Z</dc:date>
    </item>
  </channel>
</rss>

