Newer Version Available
Presenting User Error Messages
You can use Canvas.CanvasRenderException to display error
messages to the user.
If you throw a CanvasRenderException from your onRender() implementation, the error message in that exception will be displayed to the user in the Salesforce UI. This exception will be managed only within the onRender() method.
CanvasRenderException supports all the standard Apex exception class methods and constructors. See ”Exception Class and Build-In Exceptions” in the Force.com Apex Code Developer’s Guide for more information on Apex exceptions.
Here’s an example onRender() implementation that throws a Canvas.CanvasRenderException. Salesforce uses this exception and displays “Error: Could not set URL”
as the user error message.
If the canvas app is run from the Salesforce Chatter tab, the error message resembles: