All exception classes support built-in methods for returning the error message and exception type. See Exception Class and Built-In Exceptions.
The Canvas namespace contains this exception:
Exception | Description |
---|---|
Canvas.CanvasRenderException | Use this class in your implementation of Canvas.CanvasLifecycleHandler.onRender(renderContext). To show an error to the user in your onRender() implementation, throw a Canvas.CanvasRenderException, and the canvas framework will render the error message to the user. This exception will be managed only within the onRender() method. |
public class MyCanvasListener implements Canvas.CanvasLifecycleHandler { public void onRender(Canvas.RenderContext renderContext) { Canvas.ApplicationContext app = renderContext.getApplicationContext(); // Code to generate a URL string that is too long ... // Try to set the canvas app URL using the invalid URL string try { app.setCanvasUrlPath(aUrlPathThatIsTooLong); } catch (CanvasException e) { // Display error to user by throwing a new CanvasRenderException throw new CanvasRenderException(e.getMessage()); } } }