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
This is the code creating the error:
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.
Thank you for that traceback information! After testing, the arcpy. AddError('message') then exit() returns only the 'message' string as expected. However, there are always at least 5 messages returned if the job fails.
Is there any documentation that defines the number of esriJobMessageTypeInformative and orvesriJobMessageTypeError that will be returned from the server by default? I have the message level set to 'error', yet those first two informative entries always appear. Additionally, there are always two error messages at the end informing me the tool has failed. It would be great to have some ESRI documentation to send to the web team so they know the error message will be consistent.
Those starting and ending messages are consistent with what appears in my environment. The message level appears to ignore those 2 leading messages and you always get 2 ending errors so I think you've hit the limit. Luckily the only internal info being leaked is the tool name so if you're able to instruct your users to ignore the other messages then you're good.