GetMaxSeverity

Resumen

Gets the maximum severity returned from the previously run tool.

Sintaxis

GetMaxSeverity ()
Valor de retorno
Tipo de datosExplicación
Integer

The returned severity.

  • 0The tool returned neither a warning nor an error message.
  • 1The tool returned a warning message, but not an error message.
  • 2The tool returned an error message.

Muestra de código

GetMaxSeverity example

Displays a custom message based on maximum severity of the previously run tool.

import arcpy

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

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

severity = arcpy.GetMaxSeverity()

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

Temas relacionados


En este tema