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.'