is there a way to not show the message when I get a unexpected error?
I´ve tryed to do it changed cuba.web.productionMode=true
. . . from web-app-properties but it keep showing the message . . .
thank a lot!
is there a way to not show the message when I get a unexpected error?
I´ve tryed to do it changed cuba.web.productionMode=true
. . . from web-app-properties but it keep showing the message . . .
thank a lot!
Hello @mangel.gonzalez
The cuba.web.productionMode app property enables to manage whether Vaadin developer console can be opened or not.
All unexpected errors are handled by DefaultExceptionHandler
. So I suggest you to implement your own exception handler and, for example, just log exceptions. Please read our documentation for more details: Client-Level Exception Handlers.
Regards,
Daniil.
Hello Danii,
In the follow example I get to catch the exception “SQLException”;
@Component("sample_AdqExceptionHandler")
public class AdqExceptionHandler extends AbstractGenericExceptionHandler{
private Logger log = LoggerFactory.getLogger(AdqExceptionHandler.class);
public AdqExceptionHandler() {
super(JPQLException.class.getName());
}
@Override
protected void doHandle(String className, String message, @Nullable Throwable throwable, WindowManager windowManager) {
log.error("ERROR: TEST DefaultExceptionHandler");
}
}
I´ve tried to catch the exceptions; EclipseLinkException, RuntimeException and Exception in the same way but it´s not working!!!. . . . . . do you know how could I do it?
Thank a lot!
Could you share a code that you use to handle these exceptions?
Yes of course!! . . . . Thank a lot!!
I use the follow example to handle the exception “EclipseLinkException” . . … . but it´s not working
@Component("sample_AdqExceptionHandlerEclipseLink")
public class AdqExceptionHandlerEclipseLink extends AbstractGenericExceptionHandler{
private Logger log = LoggerFactory.getLogger(AdqExceptionHandlerEclipseLink.class);
public AdqExceptionHandlerEclipseLink() {
super(EclipseLinkException.class.getName());
}
@Override
protected void doHandle(String className, String message, @Nullable Throwable throwable, WindowManager windowManager) {
log.error("ERROR: TEST AdqExceptionHandlerEclipseLink");
if (throwable != null)
windowManager.showExceptionDialog(throwable, "Exception is thrown", message);
}
}
I use the follow example to handle the exception “RuntimeException” . . … . but it´s not working
@Component("sample_AdqExceptionHandleRuntime")
public class AdqExceptionHandleRuntime extends AbstractGenericExceptionHandler{
private Logger log = LoggerFactory.getLogger(AdqExceptionHandleRuntime.class);
public AdqExceptionHandleRuntime() {
super(RuntimeException.class.getName());
}
@Override
protected void doHandle(String className, String message, @Nullable Throwable throwable, WindowManager windowManager) {
log.error("ERROR: TEST AdqExceptionHandleRuntime");
if (throwable != null)
windowManager.showExceptionDialog(throwable, "Exception is thrown", message);
}
}
I use the follow example to handle the exception “Exception”. . … . but it´s not working
@Component("sample_AdqExceptionHandleException")
public class AdqExceptionHandleException extends AbstractGenericExceptionHandler{
private Logger log = LoggerFactory.getLogger(AdqExceptionHandleException.class);
public AdqExceptionHandleException() {
super(Exception.class.getName());
}
@Override
protected void doHandle(String className, String message, @Nullable Throwable throwable, WindowManager windowManager) {
log.error("ERROR: TEST AdqExceptionHandleException");
if (throwable != null)
windowManager.showExceptionDialog(throwable, "Exception is thrown", message);
}
}
Please note that if you want to use the same class for few exception types you have to pass their class names into super like this:
public AdqExceptionHandlerEclipseLink() {
super(EclipseLinkException.class.getName(),
RuntimeException.class.getName(),
Exception.class.getName());
}
Where is your exception handler located?
Hi Daniil,
Thanks for your answer.
The examples I posted above are independent. I don’t have any problems catching multiple exceptions, but catching specific exceptions.
For example, I can catch JPQLException just fine with AdqExceptionHandleException
. But EclipseLinkException, RuntimeException and Exception are all catched by CUBA’s DefaultExceptionHandler
even after changing super(JPQLException.class.getName());
for super(Exception.class.getName());
in my custom exception handling class.
All my exception handling classes are located in the web module at com.company.exceptions.AdqExceptionHandleException.
Best regards.
In another word, I would like to use AdqExceptionHandler to catch whatever exception not only JPQLException… . . thanks a lot!!!
@Component("sample_AdqExceptionHandler")
public class AdqExceptionHandler extends AbstractGenericExceptionHandler{
private Logger log = LoggerFactory.getLogger(AdqExceptionHandler.class);
public AdqExceptionHandler() {
super(JPQLException.class.getName());
}
@Override
protected void doHandle(String className, String message, @Nullable Throwable throwable, WindowManager windowManager) {
log.error("ERROR: TEST DefaultExceptionHandler");
if (throwable != null)
windowManager.showExceptionDialog(throwable, "Exception is thrown", "My custom exception");
}
}
I’ve prepared an example for you. Please look for CustomExceptionHandler
and exceptions thrown from Screen
ex-handlers.zip (71.3 KB)
Hope it’ll help you
Regards,
Daniil
Hello Danii, thank you for your valuable example, my problem is over !! you have helped me a lot !!
I really appreciate it !!
Best regards.
You are welcome!