AnsweredAssumed Answered

Getting error messages for python scripts run in .NET application

Question asked by MollyKFoley on Nov 8, 2017
Latest reply on Nov 9, 2017 by MollyKFoley

I feel like I'm missing something really obvious, but I can't figure this out. I use ArcObjects to call out to a python script using gp.execute(). When that python script encounters an error, the c# script will stop executing, leaving me no way to get error messages from the python script because anything like gp.GetMessage(ref sev) has to come after the python script call, so it's never hit when the script is erroneous. How do you get your error messages??

 

Example:

//junk here
gp.Execute("myscript", parameters, null); //error occurs here
gp.GetMessages(ref sev); //cannot actually get these messages because c# script stops executing

What about try/catch blocks?

try{
//junk here
gp.Execute("my script, parameters, null) //error occurs
}
catch{
gp.GetMessages(ref sev) //can't reference gp object here because it is not in scope
}

Outcomes