My code is as follows:

Essentially, I have one table in my database that is not able to convert into my FGDB. When I run on command line, I am able to get an error message of:

WARNING: Failed to convert Database Connections\DB.sde\Tablexxx. ERROR 999999: Error executing function.

Failed to execute (CopyRows).

But i am not able to print/write this error message to console (via print statement) or to a log file (via log.write). It seems that in my code, the except statements are not even being reached, even though an error is occuring?

  • Your indentation for the second and third lines of code that you have presented is astray. I think you should print(tables) as a new first line. You have a tag for file geodatabase but seem to be using an enterprise geodatabase.
    – PolyGeo
    Jul 23, 2019 at 20:57
  • arcpy.AddError only functions with an ArcGIS script tool or Python toolbox tool. Is this a stand-alone script? Jul 23, 2019 at 22:25
  • 2
    print does not work within the ArcGIS platform. You want arcpy.AddMessage or its siblings, arcpy.AddWarning, arcpy.AddError. Just for grins, the messages object in Python toolbox uses messages.addMessage (lowercase a in add) and messages.addWarningMessage and messages.addErrorMessage (gotta stay on your toes)
    – Vince
    Jul 24, 2019 at 0:40
  • This, gis.stackexchange.com/a/160436/28687, may help. This is about piping your stream to be handled by right medium, I think.
    – fatih_dur
    Jul 24, 2019 at 1:18
  • I’m not clear why you’ve deleted your code from this coding question. What precisely did you run from the “command line” and by that do you mean the Python window of ArcMap or something else?
    – PolyGeo
    Aug 11, 2019 at 20:37

2 Answers 2


I'd just use except Exception as e:

>>> import arcpy
>>> try:
    arcpy.Buffer_analysis ("fdgfd", "dfgdg", "dsfsdfsd")
except Exception as e:
    print e

Failed to execute. Parameters are not valid.
ERROR 000732: Input Features: Dataset fdgfd does not exist or is not supported
Failed to execute (Buffer).

  • I tried this as well but the error message still does not show up Jul 23, 2019 at 23:37

You are using print in one statement and arcpy.AddError() in another. The command line won't print errors from AddError() and the ArcGIS console won't print from print.

To be able to print the error both within the ArcGIS console and the command line you may want to use both print and AddError() from within your except statements:

except arcpy.ExecuteError:

    e = sys.exc_info()[1]

Not the answer you're looking for? Browse other questions tagged or ask your own question.