ArcGIS Desktop

  • ArcGIS Pro
  • ArcMap

  • My Profile
  • Help
  • Sign Out
ArcGIS Desktop

ArcGIS Online

The mapping platform for your organization

ArcGIS Desktop

A complete professional GIS

ArcGIS Enterprise

GIS in your enterprise

ArcGIS Developers

Tools to build location-aware apps

ArcGIS Solutions

Free template maps and apps for your industry

ArcGIS Marketplace

Get apps and data for your organization

  • Documentation
  • Support
Esri
  • Sign In
user
  • My Profile
  • Sign Out

ArcMap

  • Home
  • Get Started
  • Map
  • Analyze
  • Manage Data
  • Tools
  • Extensions

SetSeverityLevel

  • Summary
  • Discussion
  • Syntax
  • Code sample

Summary

Used to control how geoprocessing tools throw exceptions.

Discussion

If SetSeverityLevel is not used, the default behavior is equivalent to setting the severity_level to 2; that is, tools will only throw an exception when the tool has an error.

Syntax

SetSeverityLevel (severity_level)
ParameterExplanationData Type
severity_level

The severity level

  • 0 —A tool will not throw an exception, even if the tool produces an error or warning.
  • 1 —If a tool produces a warning or an error, it will throw an exception.
  • 2 —If a tool produces an error, it will throw an exception. This is the default.
Integer

Code sample

SetSeverityLevel example

Use SetSeverityLevel to force tool to throw an exception when a tool warning is encountered.

import arcpy

fc1 = 'c:/resources/resources.gdb/boundary'
fc2 = 'c:/resources/resources.gdb/boundary2'

# Set the severity level to 1 (tool warnings will throw an exception)
arcpy.SetSeverityLevel(1)
print("Severity is set to : {0}".format(arcpy.GetSeverityLevel()))

try:
    # FeatureCompare returns warning messages when a miscompare is
    #  found.  This normally would not cause an exception, however, by
    #  setting the severity level to 1, all tool warnings will also
    #  return an exception.
    arcpy.FeatureCompare_management(fc1, fc2, "OBJECTID")
except arcpy.ExecuteWarning:
    print(arcpy.GetMessages(1))
except arcpy.ExecuteError:
    print(arcpy.GetMessages(2))

Related topics

  • GetSeverityLevel

ArcGIS Desktop

  • Home
  • Documentation
  • Support

ArcGIS

  • ArcGIS Online
  • ArcGIS Desktop
  • ArcGIS Enterprise
  • ArcGIS
  • ArcGIS Developer
  • ArcGIS Solutions
  • ArcGIS Marketplace

About Esri

  • About Us
  • Careers
  • Esri Blog
  • User Conference
  • Developer Summit
Esri
Tell us what you think.
Copyright © 2021 Esri. | Privacy | Legal