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.");
return;
}
1 Answer 1
Try this:
var gpUtilites = new GPUtilitiesClass();
gpUtilites.SetMessage1Args(esriGPMessageType.esriGPMessageTypeError,427,
parameterValue, parameterPosition, messages);
-
1Could you add a bit more explanation around this answer?BradHards– BradHards2013年11月29日 05:37:31 +00:00Commented Nov 29, 2013 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– Pavel Butusov2013年11月29日 07:33:35 +00:00Commented Nov 29, 2013 at 7:33
-
Thats really odd. I can get it to work with id 735 but it does nothing with 427.TurboGus– TurboGus2013年12月12日 00:37:09 +00:00Commented Dec 12, 2013 at 0:37
-
But I was able to get it working with SetMessage2Args and error 605.TurboGus– TurboGus2013年12月12日 00:46:33 +00:00Commented Dec 12, 2013 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– TurboGus2013年12月12日 00:46:54 +00:00Commented Dec 12, 2013 at 0:46
Explore related questions
See similar questions with these tags.