Newer Version Available
Canvas Exceptions
The Canvas namespace
contains exception classes.
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. |
Example
The following example implementation of onRender()
catches a CanvasException that was thrown because a canvas URL was set with a string
that exceeded the maximum length. A CanvasRenderException is created and thrown to
display the error to the
user.
See
the Canvas Developer
Guide for additional examples that use
CanvasRenderException.
1public class MyCanvasListener
2implements Canvas.CanvasLifecycleHandler {
3
4 public void onRender(Canvas.RenderContext renderContext) {
5 Canvas.ApplicationContext app = renderContext.getApplicationContext();
6
7 // Code to generate a URL string that is too long
8
9 // ...
10
11 // Try to set the canvas app URL using the invalid URL string
12 try {
13 app.setCanvasUrlPath(aUrlPathThatIsTooLong);
14 } catch (CanvasException e) {
15 // Display error to user by throwing a new CanvasRenderException
16 throw new Canvas.CanvasRenderException(e.getMessage());
17 }
18 }
19}