GetMaxSeverity

Diese ArcGIS 2.7-Dokumentation wurde archiviert und wird nicht mehr aktualisiert. Inhalt und Links sind möglicherweise veraltet. Verwenden Sie die aktuelle Dokumentation.

Zusammenfassung

Gets the maximum severity returned from the last executed tool.

Syntax

GetMaxSeverity ()
Rückgabewert
DatentypErklärung
Integer

The returned severity.

  • 0no errors/warnings raised.
  • 1warning raised.
  • 2error raised.

Codebeispiel

GetMaxSeverity example

Displays a custom message based on maximum severity of the last executed command.

import arcpy

# Set current workspace
arcpy.env.workspace = "c:/data/mydata.gdb"

try:
    arcpy.Clip_analysis("Roads", "County", "Roads_Clip")
except arcpy.ExecuteError:
    pass

severity = arcpy.GetMaxSeverity()

if severity == 2:
    # If the tool returned an error
    print("Error occurred \n{0}".format(arcpy.GetMessages(2)))
elif severity == 1:
    # If the tool returned no errors, but returned a warning
    print("Warning raised \n{0}".format(arcpy.GetMessages(1)))
else:
    # If the tool did not return an error or a warning
    print(arcpy.GetMessages())

Verwandte Themen


In diesem Thema