<?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: Can't access to the errors with GetMessages() in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/can-t-access-to-the-errors-with-getmessages/m-p/475095#M37211</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;I'd have a look through this topic.... &lt;/SPAN&gt;&lt;BR /&gt;&lt;A href="http://resources.arcgis.com/en/help/main/10.1/#/Understanding_message_types_and_severity/002z0000000p000000/"&gt;http://resources.arcgis.com/en/help/main/10.1/#/Understanding_message_types_and_severity/002z0000000p000000/&lt;/A&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;But what I think is happening.... you're trying to make the tool "error". The tool hasn't actually errored because it hasn't run.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;The GetMessages is used to get messages from the tool execution (which hasnt occurred). You're seeing a validation error.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Thu, 25 Oct 2012 23:02:43 GMT</pubDate>
    <dc:creator>KevinHibma</dc:creator>
    <dc:date>2012-10-25T23:02:43Z</dc:date>
    <item>
      <title>Can't access to the errors with GetMessages()</title>
      <link>https://community.esri.com/t5/python-questions/can-t-access-to-the-errors-with-getmessages/m-p/475092#M37208</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Greetings to all&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I'm not getting access to the error messages with arcpy.GetMessages arcpy () and related functions. I'm really frustrated with this problem. For example, if I run on the Windows:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="plain" name="code"&gt;arcpy.GetCount_management ("c :/ temp/solapes2.shp")&lt;/PRE&gt;&lt;DIV style="display:none;"&gt; &lt;/DIV&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;(where there is not solapes2.shp shape at the location indicated)&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I get the following error message:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="plain" name="code"&gt;&amp;lt;class'arcgisscripting.ExecuteError'&amp;gt; Runtime error: ERROR 000732: Input Rows: c :/ temp/solapes2.shp the dataset does not exist or does not support&lt;/PRE&gt;&lt;DIV style="display:none;"&gt; &lt;/DIV&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;But if I execute, for example:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="plain" name="code"&gt;import arcpy
try:
**** result = arcpy.GetCount_management ("c :/ temp/solapes2.shp")
except:
arcpy.GetMessageCount print ()
arcpy.GetMessages print (2)&lt;/PRE&gt;&lt;DIV style="display:none;"&gt; &lt;/DIV&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I only get:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="plain" name="code"&gt;0

&lt;/PRE&gt;&lt;DIV style="display:none;"&gt; &lt;/DIV&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;(that is, a zero from GetMessageCount and a blank line from getMessages (2).&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Where is the problem? Am I wrong with the way errors are handled in the Python window? I tried several scripts that appear in the Help and their behavior is similar to that describe ....&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Thanks in advance&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Jesús de Diego&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Pd. I'm using ArcGIS 10.0, sp5. in a Windows 7 64 bits OS.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 25 Oct 2012 16:55:40 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/can-t-access-to-the-errors-with-getmessages/m-p/475092#M37208</guid>
      <dc:creator>Anonymous User</dc:creator>
      <dc:date>2012-10-25T16:55:40Z</dc:date>
    </item>
    <item>
      <title>Re: Can't access to the errors with GetMessages()</title>
      <link>https://community.esri.com/t5/python-questions/can-t-access-to-the-errors-with-getmessages/m-p/475093#M37209</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Does something like this work if you try it?&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;[HTML]&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;import arcpy&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;arcpy.GetCount_management("C:/temp/solapes2.shp")&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;print arcpy.GetMessages()&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;[/HTML]&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;The spaces in the path to the shapefile may be cause of the first error.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 25 Oct 2012 18:24:01 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/can-t-access-to-the-errors-with-getmessages/m-p/475093#M37209</guid>
      <dc:creator>JillianPenney</dc:creator>
      <dc:date>2012-10-25T18:24:01Z</dc:date>
    </item>
    <item>
      <title>Re: Can't access to the errors with GetMessages()</title>
      <link>https://community.esri.com/t5/python-questions/can-t-access-to-the-errors-with-getmessages/m-p/475094#M37210</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Hello Jill&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Thank you for your answer. However, what I really want is force the error... What I want to ask is why the GetMessages function is not showing any error...&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Thanks&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Jesús&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 25 Oct 2012 22:28:59 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/can-t-access-to-the-errors-with-getmessages/m-p/475094#M37210</guid>
      <dc:creator>Anonymous User</dc:creator>
      <dc:date>2012-10-25T22:28:59Z</dc:date>
    </item>
    <item>
      <title>Re: Can't access to the errors with GetMessages()</title>
      <link>https://community.esri.com/t5/python-questions/can-t-access-to-the-errors-with-getmessages/m-p/475095#M37211</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;I'd have a look through this topic.... &lt;/SPAN&gt;&lt;BR /&gt;&lt;A href="http://resources.arcgis.com/en/help/main/10.1/#/Understanding_message_types_and_severity/002z0000000p000000/"&gt;http://resources.arcgis.com/en/help/main/10.1/#/Understanding_message_types_and_severity/002z0000000p000000/&lt;/A&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;But what I think is happening.... you're trying to make the tool "error". The tool hasn't actually errored because it hasn't run.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;The GetMessages is used to get messages from the tool execution (which hasnt occurred). You're seeing a validation error.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 25 Oct 2012 23:02:43 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/can-t-access-to-the-errors-with-getmessages/m-p/475095#M37211</guid>
      <dc:creator>KevinHibma</dc:creator>
      <dc:date>2012-10-25T23:02:43Z</dc:date>
    </item>
    <item>
      <title>Re: Can't access to the errors with GetMessages()</title>
      <link>https://community.esri.com/t5/python-questions/can-t-access-to-the-errors-with-getmessages/m-p/475096#M37212</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Hello Kevin&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;mm.... but... when can I get severity 2 messages if I use arcpy.GetMessages(2). &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;And also, if I want the get error messages in the except clause, the only way is capturing the exception message? Like this way?&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;except Exception as e:&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp; print e.message&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;Jesús de Diego&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 29 Oct 2012 21:53:24 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/can-t-access-to-the-errors-with-getmessages/m-p/475096#M37212</guid>
      <dc:creator>Anonymous User</dc:creator>
      <dc:date>2012-10-29T21:53:24Z</dc:date>
    </item>
    <item>
      <title>Re: Can't access to the errors with GetMessages()</title>
      <link>https://community.esri.com/t5/python-questions/can-t-access-to-the-errors-with-getmessages/m-p/475097#M37213</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;BLOCKQUOTE class="jive-quote"&gt;If I want the get error messages in the except clause, the only way is capturing the exception message?&amp;nbsp; Like this way?&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;
except Exception as e:
&amp;nbsp;&amp;nbsp;&amp;nbsp; print e.message&lt;/PRE&gt;&lt;/BLOCKQUOTE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Yes.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;
import arcpy
try:
&amp;nbsp;&amp;nbsp;&amp;nbsp; result = arcpy.GetCount_management("c:/temp/solapes2.shp")
&amp;nbsp;&amp;nbsp;&amp;nbsp; # print tool messages if successful
&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.AddMessage(arcpy.GetMessages(0)) # to ArcGIS (script tool)
&amp;nbsp;&amp;nbsp;&amp;nbsp; print arcpy.GetMessages(0) # to stdout
except arcpy.ExecuteError:
&amp;nbsp;&amp;nbsp;&amp;nbsp; # tool failed
&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.AddError(arcpy.GetMessages(0)) # to ArcGIS
&amp;nbsp;&amp;nbsp;&amp;nbsp; print arcpy.GetMessages(0) # to stdout
except Exception, msg:
&amp;nbsp;&amp;nbsp;&amp;nbsp; # other errors (say, Python syntax)
&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.AddError(str(msg)) # to ArcGIS
&amp;nbsp;&amp;nbsp;&amp;nbsp; print arcpy.GetMessages(0) # to stdout
&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;There are some nice examples here:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;A href="http://help.arcgis.com/en/arcgisdesktop/10.0/help/index.html#//002z0000000q000000" rel="nofollow noopener noreferrer" target="_blank"&gt;Arc 10 help: Error handling with Python&lt;/A&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 21:00:23 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/can-t-access-to-the-errors-with-getmessages/m-p/475097#M37213</guid>
      <dc:creator>curtvprice</dc:creator>
      <dc:date>2021-12-11T21:00:23Z</dc:date>
    </item>
    <item>
      <title>Re: Can't access to the errors with GetMessages()</title>
      <link>https://community.esri.com/t5/python-questions/can-t-access-to-the-errors-with-getmessages/m-p/475098#M37214</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;BLOCKQUOTE class="jive-quote"&gt;Yes.&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;
import arcpy
try:
&amp;nbsp;&amp;nbsp;&amp;nbsp; result = arcpy.GetCount_management("c:/temp/solapes2.shp")
&amp;nbsp;&amp;nbsp;&amp;nbsp; # print tool messages if successful
&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.AddMessage(arcpy.GetMessages(0)) # to ArcGIS (script tool)
&amp;nbsp;&amp;nbsp;&amp;nbsp; print arcpy.GetMessages(0) # to stdout
except arcpy.ExecuteError:
&amp;nbsp;&amp;nbsp;&amp;nbsp; # tool failed
&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.AddError(arcpy.GetMessages(0)) # to ArcGIS
&amp;nbsp;&amp;nbsp;&amp;nbsp; print arcpy.GetMessages(0) # to stdout
except Exception, msg:
&amp;nbsp;&amp;nbsp;&amp;nbsp; # other errors (say, Python syntax)
&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.AddError(str(msg)) # to ArcGIS
&amp;nbsp;&amp;nbsp;&amp;nbsp; print arcpy.GetMessages(0) # to stdout
&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;There are some nice examples here:&lt;BR /&gt;&lt;BR /&gt;&lt;A href="http://help.arcgis.com/en/arcgisdesktop/10.0/help/index.html#//002z0000000q000000" rel="nofollow noopener noreferrer" target="_blank"&gt;Arc 10 help: Error handling with Python&lt;/A&gt;&lt;/BLOCKQUOTE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;First of all, thank you for your answer, Curtis.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;arcpy.AddError is working fine for script based toolboxes, no problem with this. However, arcpy.GetMessages is not working as I suppossed. Why GetMessages is working in a Python IDE (like WingIDE) and not in ArcGIS Python Windows?&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Thank you&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Jesús de Diego&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 21:00:26 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/can-t-access-to-the-errors-with-getmessages/m-p/475098#M37214</guid>
      <dc:creator>Anonymous User</dc:creator>
      <dc:date>2021-12-11T21:00:26Z</dc:date>
    </item>
    <item>
      <title>Re: Can't access to the errors with GetMessages()</title>
      <link>https://community.esri.com/t5/python-questions/can-t-access-to-the-errors-with-getmessages/m-p/475099#M37215</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;BLOCKQUOTE class="jive-quote"&gt; However, arcpy.GetMessages is not working as I suppossed. Why GetMessages is working in a Python IDE (like WingIDE) and not in ArcGIS Python Windows?&lt;/BLOCKQUOTE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Messages are handled differently in the ArcGIS Desktop python window. For example AddError and AddMessage do not work there, since tools display those messages without you having to explicitly tell it to. Print works though. I have found this in other IDEs as well, sometimes the arcpy.Add... messages do not appear. &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Entered the following in the ArcMap Python window. Note AddError does nothing.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;
&amp;gt;&amp;gt;&amp;gt; try:
...&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; raise
... except:
...&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; print "printprint"
...&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.AddError("errorprint")
...&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 
printprint
&amp;gt;&amp;gt;&amp;gt; &lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 21:00:29 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/can-t-access-to-the-errors-with-getmessages/m-p/475099#M37215</guid>
      <dc:creator>curtvprice</dc:creator>
      <dc:date>2021-12-11T21:00:29Z</dc:date>
    </item>
  </channel>
</rss>

