Select to view content in your preferred language

Is there a way to only return the string in a raised error for a published geoprocessing service?

61
1
Friday
Labels (1)
MBocek
by
New Contributor

I have a python geoprocessing toolbox that was published from Pro 2.9.5 to a 10.9.1 Enterprise server. I would like to display the error messages from the tool to a web UI, but I cannot find a way to only return the string in the raise error. For example, with the message level set to 'error', the tool always returns 5 messages

  • esriJobMessageTypeInformative: Submitted.
  • esriJobMessageTypeInformative: Executing...
  • esriJobMessageTypeError: Traceback (most recent call last): File "<string>", ***path removed ***  raise arcpy.ExecuteError('Shapefile is not a polygon. Input must be a polygon with a non empty feature.') arcgisscripting.ExecuteError: Shapefile is not a polygon. Input must be a polygon with a non empty feature.
  • esriJobMessageTypeError: Failed to execute (***tool name***).
  • esriJobMessageTypeError: Failed.

This is the code creating the error:

   if geom.type != 'polygon':
        raise arcpy.ExecuteError('Shapefile is not a polygon. Input must be a polygon with a non empty feature.')
 
I see an alternative would be to use arcpy.AddError, then exit() after. However, I still see an issue with additional error/informative messages being passed. Essentially, is there a way to only return the following?
 
  • esriJobMessageTypeError'Shapefile is not a polygon. Input must be a polygon with a non empty feature.'
0 Kudos
1 Reply
DavidSolari
MVP Regular Contributor

How uncaught exceptions are handled is at the discretion of whatever's running Python, which in this case is the Web Tool infrastructure, so you're limited in how you can format your errors. A long shot might be the sys.tracebacklimit global, this SO post implies it might be able to cut down on what ArcGIS can report on.

0 Kudos