2

I have made a network isolation model that lets the user pick a point on the network to simulate a pipe 'failure'/section that needs to be isolated and finds all valves that need to be turned and other affected features (hydrants, buildings, ect.). The model will output feature layers of those features found in the trace from the 4 feature classes, but only if a feature is found from the trace operations. This works fine in ArcMap when ran from the catalog, but not when ran from the server.

The problem is that not all outputs will contain a record for each FC. For instance, a trace may only return a pipe section and 2-3 valves, with no building connection points or hydrants returned. This works fine in ArcMap because i use a try/except to assign the results to the output parameters of the script, so if one of the FC has no selected records, the output is not assigned with anything. When ran on the server, this does not seem to work. When i run a process with no hydrants resulting from the trace, the model fails with Error Code 20010 - Invalid return value.

Does the server not adhere to the try/except function or is there any way to return an empty feature layer if no results are returned for that FC?

4

The Try/except does work - the problem here is GP Services have defined inputs and outputs. When you publish it and go look at the REST end point of the service, you'll see how these items are defined. Your service expects an output of a certain type. When your service "fails", it doesn't return whats expected of it and you get that error.

If you don't want the error, you need to return an empty featureclass, something similiar to what would be returned when the service works. In the Try/Except you could just arcpy.SetOutput to a blank featureclass you pre-created and then arcpy.AddWarning. The warning is good as the user gets information back in the messages that something went wrong.

  • Thanks for the quick reply. Creating the empty FC worked perfectly, though I did have to set the schema and projection to the original FC data, which I found out after a few tries. – Lou Feb 2 '15 at 15:37

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.