0

I am trying to capture an error with arcpy.getmessage(2) within a try/except statement but when it fails it tells me the issue is with the getmessage, it is not returning the error that occurred in the try part. This is what I have setup to capture the error message...

try:
    arcpy.CopyFeatures_management(Flow_Arrow, Flow_Arrow__2_, "", "0", "0", "0")
    print "Flow Arrow Updated"
    print "Flow Direct Feature Set Updated"
except:
    print "Error"
    print arcpy.getmessage(2)

I know it has got to be something simple I am just overlooking, I tried arcpy.getmessage(), and arcpy.getmessage(0), I went with the (2) because I was googling the issue it was one of the proposed solutions.

  • 3
    Shouldn't it be arcpy.GetMessage(2)? Python is a case sensitive language so getmessage isn't the same as GetMessage – Michael Stimson Nov 12 '14 at 21:00
4

Python is case sensitive, GetMessage should be capitalized

try:
    arcpy.CopyFeatures_management(Flow_Arrow, Flow_Arrow__2_, "", "0", "0", "0")
    print "Flow Arrow Updated"
    print "Flow Direct Feature Set Updated"
except:
    print "Error"
    print arcpy.GetMessage(2)
  • Bloody hell! Thanks guys, I am going to go and put my dunce cap on. – Tyler Veinot Nov 13 '14 at 15:03

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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