kuiperfoliage

Changed behavior of AddError

Discussion created by kuiperfoliage on May 1, 2012
Hi,

I can't test it against ArcGIS Desktop 10.0, but i'm under the impression that the AddError() functionality behavior has changed.

In the past it would just print out an error message, but in 10.1 Prerelease it actually make your script fail at the end of the run.

Here is an example
#!/usr/bin/env python

import arcpy

def main():
    pass

if __name__ == '__main__':
    main()

try:
    raise Exception('proof')
except:
    print 'handled!'
    arcpy.AddError('error')


Executing: Script
Start Time: Tue May 01 14:20:47 2012
Running script Script...
error
Completed script Script...
Failed to execute (Script).
Failed at Tue May 01 14:20:47 2012 (Elapsed Time: 0.00 seconds)


When removed (commented):


Executing: Script
Start Time: Tue May 01 14:21:14 2012
Running script Script...
Completed script Script...
Succeeded at Tue May 01 14:21:14 2012 (Elapsed Time: 0.00 seconds)


I just wanted to share this with the community. I had to update existing scripts that I used in 10.0, because they were failing on this error/feature.

Outcomes