Client-Level Exception Handlers


I struggle to display a notification from middleware service to client tier.
I made a new Exception class that actually is triggered in Catalina.out and I made a ControlledExceptionHandler too.
I put the ControlledExceptionHandler under Screens package (I’m not sure that is correct, I tried to put in Core level but I don’t have access to AbstractUiExceptionHandler base class).
Unfortunatelly I don’t know how to trigger (access) this handler in Middlleware service.
(I can only injected in client tier level).

Middleware Service


}catch(Exception e){
throw new ControlledException("text"); //it works
//handler call??


 public  class ControlledExceptionHandler extends AbstractUiExceptionHandler {

        	public ControlledExceptionHandler() {


 	 protected void doHandle(String className, String message, @Nullable Throwable throwable, UiContext context) {
//	     windowManager.showNotification("Title", message, Frame.NotificationType.ERROR);
                         .withCaption("`My message which has to be displayed in client tier` ")


    public boolean handle(Throwable exception, UiContext context) {
        return super.handle(exception, context);

    protected boolean canHandle(String className, String message, @Nullable Throwable throwable) {
        return StringUtils.containsIgnoreCase(message, " ");

Please advise!

Hello @neutrino,

In Middleware Service you are throwing a ControlledException with the “text” message.

In ControlledExceptionHandler you are trying to handle an exception with a message that contains a space. But there is no space in the error message (“text”).
The canHandle(String className, String message, @Nullable Throwable throwable) method is used if the name of the exception class is insufficient to make a decision whether this handler can be applied to the exception.


Hello Gleb,

Now it works but doesn’t help me too much.
It worksonly if in the client method I don’t cath the ControlledException. When the ControlledException arrise the handler do its job.

But I can throws Exception at the method signature level and cath the ControlledException below (without use any handler).

catch (ControlledException d){
                    .withCaption("My message which has to be displayed in client tier" )


If I use general Exception the handler doesn’t work.
I need to catch all exceptions without Controlled exception(with a notification) and Controlled exception(with another/different notification). Of course I can do treating all exceptions but I thouhgt the handler can help me.

catch (Exception e) {
//my code
//my notification


Hello @neutrino,

Link to documentation.

Unhandled exceptions thrown on the client tier or passed from Middleware, are passed to the special handlers mechanism of the Web Client block.

Client-level exception handlers handle only unhandled exceptions thrown on the client tier or passed from Middleware. Therefore, you cannot handle exceptions with client-level exception handlers that you already handle in Middleware service.


1 Like