24.9. Handling Exceptions


When invoking a remote component method, you can specify an exception handler to process the response in the event of an exception during component invocation. To specify an exception handler function, include a reference to it after the callback parameter in your JavaScript:
var callback = function(result) { 
    alert(result); 
}; 
var exceptionHandler = function(ex) { 
    alert("An exception occurred: " + ex.getMessage()); 
}; 
Seam.Component.getInstance("helloAction")
    .sayHello(name, callback, exceptionHandler);
Copy to Clipboard Toggle word wrap
If you do not have a callback handler defined, you must specify null in its place:
var exceptionHandler = function(ex) { 
    alert("An exception occurred: " + ex.getMessage()); 
}; 
Seam.Component.getInstance("helloAction")
    .sayHello(name, null, exceptionHandler);
Copy to Clipboard Toggle word wrap
The exception object that is passed to the exception handler exposes one method, getMessage(), which returns the exception message belonging to the exception thrown by the @WebRemote method.
Back to top
Red Hat logoGithubredditYoutubeTwitter

Learn

Try, buy, & sell

Communities

About Red Hat Documentation

We help Red Hat users innovate and achieve their goals with our products and services with content they can trust. Explore our recent updates.

Making open source more inclusive

Red Hat is committed to replacing problematic language in our code, documentation, and web properties. For more details, see the Red Hat Blog.

About Red Hat

We deliver hardened solutions that make it easier for enterprises to work across platforms and environments, from the core datacenter to the network edge.

Theme

© 2025 Red Hat