GetSeverity

Zusammenfassung

Gets the severity code (0, 1, 2) of the specified message by index.

Syntax

GetSeverity (Index)
ParameterErläuterungDatentyp
Index

Numeric index position of the message in the stack.

Integer
Rückgabewert
DatentypErläuterung
Integer

Severity code of the message.

  • 0message
  • 1warning
  • 2error

Codebeispiel

GetSeverity example

Returns the severity code for the specified message.

import arcpy

inFeatureClass = arcpy.GetParameterAsText(0)
outFeatureClass = arcpy.GetParameterAsText(1)

# Run the CopyFeatures Tool.  If it fails, print out the error messages
#
try:
    arcpy.CopyFeatures_management(inFeatureClass, outFeatureClass)
except:
    messageIndex = 0
    # Loop through the messages and check severity level
    #
    while messageIndex < arcpy.GetMessageCount:
        if arcpy.GetSeverity(messageIndex) == 2:
            # Print the error message
            #
            print arcpy.GetMessage(messageIndex)

        messageIndex += 1
    

Verwandte Themen


7/10/2012