I have a script tool in ArcGIS 10.2 and I have altered the tool's validation code to show my custom error messages using setErrorMessage method. It works but when an error message is displayed it shows error code -1 (ERROR -1) together with the message text, and since it doesn't link to anything I don't want to show it at all.

Custom message looks like this:

enter image description here

I have been looking for this in the documentation but I can't find it. How can I hide it or prevent it to show?

Here's my validation code:

  def updateMessages(self):
    """Modify the messages created by internal validation for each tool
    parameter.  This method is called after internal validation."""

    if self.params[0].value:
      if not arcpy.Exists(self.params[0].value):
        self.params[0].setErrorMessage("Invalid geodatabase: path typed incorrectly or it does not exist.")
        desc1 = arcpy.Describe(self.params[0].value)
        if desc1.workspaceFactoryProgID != 'esriDataSourcesGDB.AccessWorkspaceFactory.1':
          self.params[0].setErrorMessage("This workspace is not a personal geodatabase")

    if self.params[1].value:
      if not arcpy.Exists(self.params[1].value):
        self.params[1].setErrorMessage("Invalid database connection: path typed incorrectly or it does not exist.")
        desc2 = arcpy.Describe(self.params[1].value)
        if desc2.workspaceFactoryProgID != 'esriDataSourcesGDB.SdeWorkspaceFactory.1':
          self.params[1].setErrorMessage("This workspace is not an SDE database connection.")

  • 1
    In your parameters, have you set MDB to be a personal geodatabase? It's possible that the database you chose is a File Geodatabase. – Fezter Dec 17 '14 at 11:41
  • 1
    Yes. I know some users will write text in the MDB text box instead of browsing a personal Geodatabase. That's why I have customized my tool's validation code. So I do want this message to show, but not the 'ERROR -1' part, which is the same we see in ArcGIS system tools but with a 6 digit number like this – DMS02 Dec 17 '14 at 11:52
  • 1
    could you please add your code concerning your error ? Maybe a workaround is to use a warning message instead of an error message (error message have ID codes) – radouxju Dec 17 '14 at 13:01
  • 1
    Yeah, buta warning message lets me run the tool despite parameters are not valid. :/ (Edited my question to add my validation code) – DMS02 Dec 17 '14 at 14:53