ExecuteWarning (arcpy)

サマリ

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.

コードのサンプル

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)

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

except arcpy.ExecuteWarning:
    print arcpy.GetMessages()

関連トピック

9/14/2013