<?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: Error Handling: Try Exception in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/error-handling-try-exception/m-p/145229#M11330</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;BLOCKQUOTE class="jive-quote"&gt;&lt;BR /&gt;I wanted to find out if its possible to execute a tool and if the tool has a problem processing a particular feature within a feature class will through an exception, report the feature that it has a problem with, but at least will move to the next feature within the feature class and continue processing.&lt;BR /&gt;&lt;BR /&gt;&lt;/BLOCKQUOTE&gt;&lt;BR /&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Ok so from this I take you want to do 2 things:&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;1. Loop through each feature and report problems if they occur, and&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;2. Continue processing all the remaining features.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;You can narrow you exception reporting by doing the following:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;try:
# place your code here for looping through each feature
except Exception, e:
&amp;nbsp;&amp;nbsp;&amp;nbsp; print "feature error: %s" % e
sys.exc_clear()&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;You may want to consider writing out a text file to store these feature errors.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;The last line should allow the script to continue and is preferable to 'pass'&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Anyway without seeing you code it is difficult to provide a generic solution so you probably want to test this on a small dataset first. Hope it helps.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Sat, 11 Dec 2021 07:56:27 GMT</pubDate>
    <dc:creator>ColinConstance</dc:creator>
    <dc:date>2021-12-11T07:56:27Z</dc:date>
    <item>
      <title>Error Handling: Try Exception</title>
      <link>https://community.esri.com/t5/python-questions/error-handling-try-exception/m-p/145228#M11329</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;I've developed a model within ModelBuilder that utilizes a large number of tools from various toolboxes as well as python scripts. I'm pretty new to Python as well as Programming. The model that I've developed is calculating the catchment characteristics for very large railway alignments in the excess of 1000 km alignments. If any of the tools within my model fail, it means rerunning the model from scratch. Now most of the errors that I receive is not syntax or incorrect datatypes, it more to do with the particular feature within the Feature Class being processed. &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I wanted to find out if its possible to execute a tool and if the tool has a problem processing a particular feature within&amp;nbsp; a feature class will through an exception, report the feature that it has a problem with, but at least will move to the next feature within the feature class and continue processing.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I can then going through the feature that are causing the tool to through an exception to see why and run these features separately.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Any suggestions will be appreciated.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Regards&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 20 May 2013 20:04:20 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/error-handling-try-exception/m-p/145228#M11329</guid>
      <dc:creator>PeterWilson</dc:creator>
      <dc:date>2013-05-20T20:04:20Z</dc:date>
    </item>
    <item>
      <title>Re: Error Handling: Try Exception</title>
      <link>https://community.esri.com/t5/python-questions/error-handling-try-exception/m-p/145229#M11330</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;BLOCKQUOTE class="jive-quote"&gt;&lt;BR /&gt;I wanted to find out if its possible to execute a tool and if the tool has a problem processing a particular feature within a feature class will through an exception, report the feature that it has a problem with, but at least will move to the next feature within the feature class and continue processing.&lt;BR /&gt;&lt;BR /&gt;&lt;/BLOCKQUOTE&gt;&lt;BR /&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Ok so from this I take you want to do 2 things:&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;1. Loop through each feature and report problems if they occur, and&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;2. Continue processing all the remaining features.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;You can narrow you exception reporting by doing the following:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;try:
# place your code here for looping through each feature
except Exception, e:
&amp;nbsp;&amp;nbsp;&amp;nbsp; print "feature error: %s" % e
sys.exc_clear()&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;You may want to consider writing out a text file to store these feature errors.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;The last line should allow the script to continue and is preferable to 'pass'&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Anyway without seeing you code it is difficult to provide a generic solution so you probably want to test this on a small dataset first. Hope it helps.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 07:56:27 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/error-handling-try-exception/m-p/145229#M11330</guid>
      <dc:creator>ColinConstance</dc:creator>
      <dc:date>2021-12-11T07:56:27Z</dc:date>
    </item>
  </channel>
</rss>

