Understanding geoprocessing tool errors and warnings |
|
Release 9.3
Last modified April 24, 2009 |
![]() ![]() ![]() Print all topics in : "Tool errors and warnings" |
Note:
This topic was updated for 9.3.1.
Tools communicate with users using messages. More critically, error and warning messages provide users with the opportunity to learn from, and adjust to, any problems. At 9.3, errors and warnings returned from geoprocessing tools have been standardized. The error messages will provide a clear indication of the error, and provide means through use of a standardized error code, to obtain more information about the error.
When a tool provides an error or warning code, you can look up that code in the help to find a richer description of the error, and further information that can be used to understand and deal with the issue. While using the geoprocessing progress dialog, commandline, or in the results tab, help for a coded error or warning can be accessed by clicking on the link provided with the message.
The error codes returned by geoprocessing can also be used in your own scripts and script tools. Messages can be identifying by scanning the remaining Tool errors and warnings page for appropriate error and warning codes. Once you've identified an appropriate code, you need to make note of the error code and any information that needs to be included in the message (normally referenced as <value>).
You find yourself in a position where you would like to add one of the standard error codes to Python script. After scanning the error and warning message section, you identify ID code 000012 as the error code you would like to use. To add this error code to your script, you'll use the AddIDMessage method along with an argument identifying whether the message will be an error or a warning, the ID code of the message minus the leading zeroes, and any argument(s) shown as <value> in the message.
gp.AddIDMessage("Error", 12, "myvalue")
import arcgisscripting import sys gp = arcgisscripting.create(9.3) inFeatureClass = gp.GetParameterAsText(0) outFeatureClass = gp.GetParameterAsText(1) try: # If the output feature class already exists, raise an error # if gp.Exists(inFeatureClass): raise "OverWriteError" else: # # Additional processing steps # except "OverwriteError": # Use message ID 12, and provide the output feature class # to complete the message. # gp.AddIDMessage("Error", 12, outFeatureClass)