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)
<SPAN class="line-numbers-rows"><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN></SPAN>
<SPAN class="comment token">#</SPAN>
<SPAN class="comment token"># GP Script tool - Message</SPAN>
<SPAN class="comment token"># for use in ModelBuilder</SPAN>
<SPAN class="keyword token">import</SPAN> arcpy
<SPAN class="comment token"># Two text parameters:</SPAN>
<SPAN class="comment token"># 0) Message type: ERROR, INFORMATIVE, WARNING</SPAN>
<SPAN class="comment token"># 1) Message text</SPAN>
msgType <SPAN class="operator token">=</SPAN> arcpy<SPAN class="punctuation token">.</SPAN>GetParameterAsText<SPAN class="punctuation token">(</SPAN><SPAN class="number token">0</SPAN><SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">.</SPAN>upper<SPAN class="punctuation token">(</SPAN><SPAN class="punctuation token">)</SPAN>
msgText <SPAN class="operator token">=</SPAN> arcpy<SPAN class="punctuation token">.</SPAN>GetParameterAsText<SPAN class="punctuation token">(</SPAN><SPAN class="number token">1</SPAN><SPAN class="punctuation token">)</SPAN>
<SPAN class="keyword token">try</SPAN><SPAN class="punctuation token">:</SPAN>
<SPAN class="comment token"># id message, format: "id 345 arg1,arg2"</SPAN>
<SPAN class="keyword token">if</SPAN> msgText<SPAN class="punctuation token">[</SPAN><SPAN class="punctuation token">:</SPAN><SPAN class="number token">2</SPAN><SPAN class="punctuation token">]</SPAN><SPAN class="punctuation token">.</SPAN>upper<SPAN class="punctuation token">(</SPAN><SPAN class="punctuation token">)</SPAN> <SPAN class="operator token">!=</SPAN> <SPAN class="string token">"ID"</SPAN><SPAN class="punctuation token">:</SPAN>
<SPAN class="keyword token">raise</SPAN> Exception
<SPAN class="keyword token">else</SPAN><SPAN class="punctuation token">:</SPAN>
msgList <SPAN class="operator token">=</SPAN> msgText<SPAN class="punctuation token">[</SPAN><SPAN class="number token">3</SPAN><SPAN class="punctuation token">:</SPAN><SPAN class="punctuation token">]</SPAN><SPAN class="punctuation token">.</SPAN>split<SPAN class="punctuation token">(</SPAN><SPAN class="punctuation token">)</SPAN>
msgID <SPAN class="operator token">=</SPAN> int<SPAN class="punctuation token">(</SPAN>msgList<SPAN class="punctuation token">[</SPAN><SPAN class="number token">0</SPAN><SPAN class="punctuation token">]</SPAN><SPAN class="punctuation token">)</SPAN>
<SPAN class="comment token"># pick up arguments, comma-separated</SPAN>
msgArgs <SPAN class="operator token">=</SPAN> <SPAN class="string token">" "</SPAN><SPAN class="punctuation token">.</SPAN>join<SPAN class="punctuation token">(</SPAN>msgList<SPAN class="punctuation token">[</SPAN><SPAN class="number token">1</SPAN><SPAN class="punctuation token">:</SPAN><SPAN class="punctuation token">]</SPAN><SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">.</SPAN>split<SPAN class="punctuation token">(</SPAN><SPAN class="string token">","</SPAN><SPAN class="punctuation token">)</SPAN>
msgArgs <SPAN class="operator token">=</SPAN> <SPAN class="punctuation token">[</SPAN>msgType<SPAN class="punctuation token">,</SPAN> msgID<SPAN class="punctuation token">]</SPAN> <SPAN class="operator token">+</SPAN> msgArgs
arcpy<SPAN class="punctuation token">.</SPAN>AddIDMessage<SPAN class="punctuation token">(</SPAN><SPAN class="operator token">*</SPAN>msgArgs<SPAN class="punctuation token">)</SPAN>
<SPAN class="keyword token">except</SPAN><SPAN class="punctuation token">:</SPAN>
<SPAN class="comment token"># text messages (no ID message)</SPAN>
<SPAN class="keyword token">if</SPAN> msgType <SPAN class="operator token">==</SPAN> <SPAN class="string token">"WARNING"</SPAN><SPAN class="punctuation token">:</SPAN>
arcpy<SPAN class="punctuation token">.</SPAN>AddWarning<SPAN class="punctuation token">(</SPAN>msgText<SPAN class="punctuation token">)</SPAN>
<SPAN class="keyword token">elif</SPAN> msgType <SPAN class="operator token">==</SPAN> <SPAN class="string token">"ERROR"</SPAN><SPAN class="punctuation token">:</SPAN>
arcpy<SPAN class="punctuation token">.</SPAN>AddError<SPAN class="punctuation token">(</SPAN>msgText<SPAN class="punctuation token">)</SPAN>
<SPAN class="keyword token">else</SPAN><SPAN class="punctuation token">:</SPAN>
arcpy<SPAN class="punctuation token">.</SPAN>AddMessage<SPAN class="punctuation token">(</SPAN>msgText<SPAN class="punctuation token">)</SPAN>
arcpy<SPAN class="punctuation token">.</SPAN>SetParameterAsText<SPAN class="punctuation token">(</SPAN><SPAN class="number token">2</SPAN><SPAN class="punctuation token">,</SPAN><SPAN class="token boolean">True</SPAN><SPAN class="punctuation token">)</SPAN>
<SPAN class="line-numbers-rows"><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN></SPAN>