I've got a python script that I run as a standalone and as a gp service in AGS (moving to 10.1 now...). For the standalone execution, I'm throwing a custom exception if there is no data found based on the user's input:
arcpy.MakeTableView_management(lookupTable, luTV, '"COMID"='+gage)
if arcpy.GetCount_management(luTV)==0:
raise Exception('UnknownIdentifier')
I'm expecting users of the AGS service to be scripting against the REST API, most likely with python, and I want to be able to pass back the same exception through the AGS web service. I have users that plan to hit my service hundreds of times using some kind of iteration--I need a clear way to let them/their code know that a request had a problem.
I'm having trouble finding information on how to I should modify my script. I can see from this question that there will be some differences if the initial request is executed synchronously (somehow directly passed) or submitted as an asynchronous job (use GPResult), although I didn't understand what these differences mean for either the user's or my code.
I'm not seeing what I think I need here, although I probably (definitely) don't understand it all. Don't know if I have to fiddle with the actual configuration of AGS's REST API--I'm really hoping to avoid needing admin privileges.
Is it really as simple as ditching my raise Exception()
syntax and using arcpy.AddMessage() instead?
Thanks for any guidance!
Updates
related posts:
-
Not getting so many nibbles here...Maybe another way to phrase this is whether or how python exceptions are propagated by AGS through a web service.Roland– Roland2013年06月06日 22:19:02 +00:00Commented Jun 6, 2013 at 22:19
-
beginning to suspect that I should use arcpy.AddMessage/AddError type functionality so that AGS can handle packaging the errors per the client-selected API (REST, SOAP, ...).Roland– Roland2013年06月07日 04:50:55 +00:00Commented Jun 7, 2013 at 4:50
-
This doc shows examples of JSON payloads returned via REST, but none include examples of an error. Talked w/ESRI a bit. We looked at returns w/fiddle. Couldn't see anything other than header information and an empty body when an error was raised on the server. He's checking w/some product specialists. While clients of the REST service could check for an empty return string, this would not indicate much about the nature of the error (wouldn't allow a custom error type).Roland– Roland2013年06月13日 22:13:52 +00:00Commented Jun 13, 2013 at 22:13