AnsweredAssumed Answered

ErrorDesc versus Err as exception

Question asked by jborgion Champion on Jun 21, 2018
Latest reply on Jun 22, 2018 by jborgion

I've been tasked with updating a number of scripts that we run over night as scheduled tasks.  The original scripts use several try: except blocks that look like this:

 

if arcpy.Exists(gdbPathNameTestBAK):   
    try:
        arcpy.Delete_management(gdbPathNameTestBAK)
        print "Success: Deleted BACKUP  " + gdbPathNameTestBAK
    except Exception, ErrorDesc:
        errorFlag = True
        EmailNoticeDeleteBack = "Error: No Delete BACKUP " + gdbPathNameTestBAK
        print str(ErrorDesc) + "Error: No Delete BACKUP " + gdbPathNameTestBAK
# note the except Exception, ErrorDesc:


EmailNoticeExportXML = "" 
try:
    arcpy.ExportXMLWorkspaceDocument_management(sdePathName, xmlWorkspacePath, "SCHEMA_ONLY", "BINARY", "NO_METADATA")
    print "Success: Exported XML workspace to " + xmlWorkspacePath
except Exception, Err:
    errorFlag = True
    EmailNoticeExportXML =  "Error: No Export XML workspace to " + xmlWorkspacePath
    print str(Err) + " Error: No Export XML workspace to " + xmlWorkspacePath
#note the except Exception Err:

My question is in regards to the except arguments.  What's the difference between ErrorDesc and Err?  Also, I've changed the the print statements to :

###original --print str(ErrorDesc) + "Error: No Delete BACKUP " + gdbPathNameTestBAK
#mine:
print'{} Error: No Delete BACKUP'.format(gdbPathNameTestBAK)

### original -- print str(Err) + " Error: No Export XML workspace to " + xmlWorkspacePath
#mine:
print '{} Error: No Export XML workspace to'.format(xmlWorkspacePath)

After running the print statements I drop the str() method as it does not seem to make a difference.  Thoughts there?

Outcomes