-
FEATURED COMPONENTS
First time here? Check out the FAQ!
I use zk 8.0.1 and Tomcat8.
I have problem with handling custom runtime exceptions. I read article ZKDeveloper'sReference/UIPatterns/ErrorHandling.
zk.xml:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE xml>
<zk>
<error-page>
<exception-type>rencap.com.portal.service.TomcatException</exception-type>
<location>/tomcatError.zul</location>
</error-page>
</zk>
TomcatException.java:
package rencap.com.portal.service;
import org.zkoss.lang.Expectable;
public class TomcatException extends Exception implements Expectable{
private static final long serialVersionUID = 1L;
public TomcatException(String result) {
super(result);
}
}
page.zul
....
<button label="Cause Error" onClick='throw new rencap.com.portal.service.TomcatException("Unknown Value")'/>
....
When I click the button, standart error message box is displayed instead of expected custom /tomcatError.zul. If I change rencap.com.portal.service.TomcatException to java.lang.Exception or java.lang.Throwable, my custom window /tomcatError.zul is displayed.
If I replace TomcatException to standart exception in zk.xml and page.zul like NullPointerException, everythink is ok, my custom window is displayed.
What do I wrong? How do I handle my custom exception?
since ZK wraps every exception with UiException except RuntimeException. If you want to handle a custom exception in a separate zul. Please create an exception that extends RuntimeException
like:
public class TomcatException extends RuntimeException
Asked: 2017-04-14 10:30:08 +0800
Seen: 38 times
Last updated: Jun 02 '17