Hi folks,
I have some preconditions to run my python script tool, for example that you have to create a local copy for editing first when using a hosted feature service layer. I can use exit() with an if statement (I also tried exit(0) and exit(1)) and it stops my script but it "pretends" to have ran succesfully which it did not (because I stopped it before proceeding). I would like to show the user a last message so he knows what he has to do before running the script again. Like the system error messages you find in that geoprocessing window but more helpful 😉
Solved! Go to Solution.
You can raise an exception (or try arcpy.AddError) and the window will stay up. But you'd be better using script validation to stop the script from running in the first place.
Where is the script being run? ArcMap? ArcGIS Pro? standalone script? some other place?
Luke already gave me the correct answer but to answer your question (and maybe to give a hint to other people reading this): I am running the script from a Script tool (from the toolbox) within ArcMap 10.6.
Ahh arcmap… in Pro, the geoprocessing dialog doesn't close and you can addmessage or error stuff, then 'view details'
You can raise an exception (or try arcpy.AddError) and the window will stay up. But you'd be better using script validation to stop the script from running in the first place.
Thanks Luke! Why I didn't find that option?! That does exactly what I was looking for.
I have script validation in my script but there are a couple of still valid steps that would throw an error at a later stage whith an error message that my client would not understand 😉