I am writing some validation in the updateparameters method of my custom geoprocessing tool. I need to post an error message when specific conditions exists and I would like to include a standard esri error code with my message. I have the logic worked out and my error message posting but I must not be using the error code correctly because no mater what number I use for the error code, it displays as -1.

enter image description here

I would like it to display error code 427.

This is the simplified code setting the error message.

 public void UpdateMessages(IArray paramvalues, IGPEnvironmentManager pEnvMgr, IGPMessages Messages)
     Messages.ReplaceError(5, 427, "You're doing it wrong.");

Try this:

var gpUtilites = new GPUtilitiesClass();
parameterValue, parameterPosition, messages);
|improve this answer|||||
  • 1
    Could you add a bit more explanation around this answer? – BradHards Nov 29 '13 at 5:37
  • I want to draw your attention to the IGPMessageManager interface. It implemented by GPMessageManagerClass and GpUtilitiesClass. I think that is what the author is looking for. For example, it allows to get message by id and use message with custom arguments. Message can have arguments, for example 735. I tested it using it error code, and it works as the author wanted. But unfortunately it does not work specifically for 427 message. – Pavel Butusov Nov 29 '13 at 7:33
  • Thats really odd. I can get it to work with id 735 but it does nothing with 427. – TurboGus Dec 12 '13 at 0:37
  • But I was able to get it working with SetMessage2Args and error 605. – TurboGus Dec 12 '13 at 0:46
  • I replaced the ReplaceError method with the following to get my desired results: var gpUtilites = new GPUtilitiesClass(); gpUtilites.SetMessage2Args(esriGPMessageType.esriGPMessageTypeError, 605, outFCName, outLocation, _outFCName.DisplayOrder, Messages); – TurboGus Dec 12 '13 at 0:46

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.