geo-processing errors in REST

Discussion created by MBaird-esristaff Employee on Dec 6, 2010
Latest reply on Mar 20, 2012 by yousifmalik

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?