Today I got a message script tool working along the lines of the one discussed in the ArcGIS Blog for use in generating messages inside ModelBuilder.
First, an example of how it works, set up as a script tool with two text arguments, the first "MESSAGE","ERROR","WARNING", the second your message. What's new about this one over the one linked from the blog is that with this version, you can do error codes by using the format: "id arg1,arg2". (Sure would be nice if a tool was provided that does this in ModelBuilder.)
Updated for ArcGIS 10x / Pro - currently testing
Executing: Message WARNING "id 591 First,Last"
Start Time: Thu Oct 18 11:58:10 2012
Running script Message...
WARNING 000591: First parameter not Last.
Completed script Message...
Succeeded at Thu Oct 18 11:58:10 2012 (Elapsed Time: 0.00 seconds)
#
# GP Script tool - Message
# for use in ModelBuilder
import arcpy
# Two text parameters:
# 0) Message type: ERROR, INFORMATIVE, WARNING
# 1) Message text
msgType = arcpy.GetParameterAsText(0).upper()
msgText = arcpy.GetParameterAsText(1)
try:
# id message, format: "id 345 arg1,arg2"
if msgText[:2].upper() != "ID":
raise Exception
else:
msgList = msgText[3:].split()
msgID = int(msgList[0])
# pick up arguments, comma-separated
msgArgs = " ".join(msgList[1:]).split(",")
msgArgs = [msgType, msgID] + msgArgs
arcpy.AddIDMessage(*msgArgs)
except:
# text messages (no ID message)
if msgType == "WARNING":
arcpy.AddWarning(msgText)
elif msgType == "ERROR":
arcpy.AddError(msgText)
else:
arcpy.AddMessage(msgText)
arcpy.SetParameterAsText(2,True)