If all you need is a warning at the time of publication (so that the message “Publish transaction had a status warning”), you need to set PublishInstruction.MaximumNumberOfRenderFailures to something greater than 0. If the number of Render errors is less than the maximum you specify, the publication status will be "A warning".
If an error occurs outside of the rendering, the instruction will be displayed as "Failure".
On the other hand, if you want to display a message in the GUI (in MessageCenter) with a “Warning” that something went wrong, you will need a more complex architecture. Frank worked on this a while ago. The idea (IIRC) is to have a part of the GUI, for example. iframe polling a service that returns statuses for this user. Post action. An event system would create these statuses, controlling PublishInstruction, and write them to the repository (file, db, memory) that the service could poll.
source share