ExecuteWarning (arcpy)

Récapitulatif

The ExecuteWarning exception class is raised when a geoprocessing tool encounters a warning, and the SetSeverityLevel function has updated the severity level to 1. Setting the severity level to 1 instructs arcpy to throw the ExecuteWarning execption when a warning is encountered.

Exemple de code

ExecuteWarning exception example

The ExecuteWarning class is used below to specifically handle any geoprocessing tool warnings that result from DeleteFeatures.

import arcpy

try:
    # If a tool produces a warning, it will throw an exception
    arcpy.SetSeverityLevel(1)

    # Note: DeleteFeatures on a feature class will always return a warning
    arcpy.DeleteFeatures_management("c:/base/transport.gdb/roads")

except arcpy.ExecuteWarning:
    print arcpy.GetMessages()

Thèmes connexes

4/26/2014