AddError (arcpy)

Zusammenfassung

Creates a geoprocessing tool error message (Severity=2) that can be accessed by any of the GetMessages functions.

Syntax

AddError (message)
ParameterErläuterungDatentyp
message

The message to add.

String

Codebeispiel

AddError example

Add custom geoprocessing error message.

import arcpy

fc = arcpy.GetParameterAsText(0)
result = arcpy.GetCount_management(fc)

# Get the count from GetCount's Result object
#
featurecount = int(result.getOutput(0))

if featurecount == 0:
    arcpy.AddError(fc + " has no features.")		
else:
    arcpy.AddMessage(fc + " has " + str(featurecount) + " features.")

Verwandte Themen

9/11/2013