geo-processing errors in REST

371
2
12-06-2010 03:46 AM
MarkBaird
Esri Regular Contributor
Hi

Using ArcGIS 9.3.1 SP 2, I've written a python script which I've published to server.  It works fine, but I've got an issue with error messages.

I've got a check in my script which detects bad input parameters.  If the data isn't any good then I throw an error with gp.AddError.

This works fine if I consume the tool using ArcCatalog (I get a helpful message which was created by my gp.AddError) , but when consuming the tool through the rest interface, if you end up running the gp.AddError section, the server returns HTTP 500:

{
  "error" :
  {
    "code" : 500,
    "message" : "Error Executing Task",
    "details" : []
  }
}

What's happened to my helpful error message?

However I change the gp.AddError to gp.AddWarning, the JSON contains the kind of information I'm looking for:

{
  "results" : [
    {
      "paramName" : "IDP",
      "dataType" : "GPString",
      "value" : ""
    }
  ],
  "messages" : [
    {"type" : "esriJobMessageTypeInformative", "description" : "Executing (Add Something): AddSomething 99 \"Record Set\" # # # #"},
    {"type" : "esriJobMessageTypeInformative", "description" : "Start Time: Mon Dec 06 13:36:15 2010"},
    {"type" : "esriJobMessageTypeInformative", "description" : "Running script AddSomething..."},
    {"type" : "esriJobMessageTypeWarning", "description" : "Here is a warning wanting to be an error!"},
    {"type" : "esriJobMessageTypeInformative", "description" : "Completed script AddSomething..."},
    {"type" : "esriJobMessageTypeInformative", "description" : "Executed (Add Something) successfully."},
    {"type" : "esriJobMessageTypeInformative", "description" : "End Time: Mon Dec 06 13:36:15 2010 (Elapsed Time: 0.00 seconds)"}
  ]
}

Why can't I have this kind of message when I use gp.AddError?  I'd quite like to be able to write a user friendly application which gives meaningful feedback when errors happen.  Is there a configuration setting to adjust this?

Thanks
0 Kudos
2 Replies
AndrewThomas
New Contributor II
Has anyone had any luck with this in 10?

I can't even get the AddWarning to work

My Python script:



arcpy.AddMessage('Begin')
arcpy.AddWarning('BlahWarning')
arcpy.AddError('BlahError')
arcpy.AddMessage('BlahMessage')

ArcCatalog Output


Executing: TestMessage
Start Time: Tue Feb 28 17:44:31 2012
Running script TestMessage...
Begin
BlahWarning
BlahError
BlahMessage
Completed script TestMessage...
Failed to execute (TestMessage).
Failed at Tue Feb 28 17:44:31 2012 (Elapsed Time: 0.00 seconds)

ArcGIS Server REST output

Job ID: j4b2583bbbe0d44e7a636a3b544a5aa96


Job Status: esriJobFailed


Job Messages:


esriJobMessageTypeInformative: Submitted.
esriJobMessageTypeInformative: Executing...
esriJobMessageTypeError: Failed.


Although, when I try as a synchronous job, I get a 500 with the AddError and empty results without

{
  "results" : [
   
  ],
  "messages" : [
   
  ]
}
0 Kudos
YousifMalik
New Contributor
Hi,

I have same issue with capturing the GP error messages using REST. 
Running the GP service on ArcMap will display all error messages!!!
[ATTACH=CONFIG]12854[/ATTACH]

Any idea on capturing messages same as ArcMap !!!

Thanks
0 Kudos