0

hundle runtime exception

asked 2017-04-14 10:30:08 +0800

typik gravatar image typik
1

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?

delete flag offensive retag edit

1 Answer

Sort by ยป oldest newest most voted
0

answered 2017-06-02 04:45:21 +0800

hawk gravatar image hawk
2255 1 5
http://hawkphoenix.blogsp... ZK Team

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
link publish delete flag offensive edit
Your answer
Please start posting your answer anonymously - your answer will be saved within the current session and published after you log in or create a new account. Please try to give a substantial answer, for discussions, please use comments and please do remember to vote (after you log in)!

[hide preview]

Question tools

Follow
1 follower

RSS

Stats

Asked: 2017-04-14 10:30:08 +0800

Seen: 36 times

Last updated: Jun 02 '17

Support Options
  • Email Support
  • Training
  • Consulting
  • Outsourcing
Learn More