Hello Glynn<div><br></div><div>What I want to do is run grass.mapcalc like this:</div><div>try:</div><div>   grass.mapcalc()</div><div>except:</div><div>   grass.fatal(_(&quot;An error occurred ...&quot;))</div><div><br></div>
<div>I know that this doesn&#39;t work. What I want to catch is not &quot;syntax&quot; erros but errors such as an raster input map that does not exist and is being used in grass.mapcal should raise an error or an excpetion in order to stop the process.</div>
<div><br></div><div>Any sugfgestions?</div><div><br>Thanks</div><div>Jenny<br><br><div class="gmail_quote">On Tue, Mar 1, 2011 at 7:26 PM, Glynn Clements <span dir="ltr">&lt;<a href="mailto:glynn@gclements.plus.com">glynn@gclements.plus.com</a>&gt;</span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;"><div class="im"><br>
Jenny Turner wrote:<br>
<br>
&gt; I want to include grass.mapcalc function in try except but I&#39;m not catching<br>
&gt; the errors. Has anyone used this for grass.mapcalc?<br>
<br>
</div>What sort of error are you expecting?<br>
<br>
If you call set_raise_on_error(), a non-zero exit status should raise<br>
a ScriptException instead of calling sys.exit() (note that sys.exit()<br>
raises a SystemExit exception, which can be caught if desired).<br>
<br>
Note that r.mapcalc will only return a non-zero exit status for<br>
fundamental errors such as syntax errors in the expression or failure<br>
to open a map. Calculation errors (e.g. division by zero or domain<br>
errors) result in null values.<br>
<font color="#888888"><br>
--<br>
Glynn Clements &lt;<a href="mailto:glynn@gclements.plus.com">glynn@gclements.plus.com</a>&gt;<br>
</font></blockquote></div><br></div>