# How to catch all Exceptions?

dastultz
797 8

Hello,

I develop apps in Richlet/Java. I have defined an error page in zk.xml like so:

<error-page>
<exception-type>java.lang.Throwable</exception-type>
<location>CriticalError.zk</location>
</error-page>

Somehow I have managed to get a 500 error from Tomcat for an uncaught exception. How did this happen? I thought the error page should be used instead.

For interest, I tried to do something silly like add a Menuitem directly to a Menu in a Listitem of a Listbox. I got this error:

org.zkoss.zk.ui.AbstractComponent.appendChild(AbstractComponent.java:1032)
sanitized.Publish$4.createCellComponent(Publish.java:208) sanitized.renderCell(AbstractListTableCellRenderer.java:18) sanitized.render(ListTableRowRenderer.java:96) org.zkoss.zul.Listbox$Renderer.render(Listbox.java:2289)
org.zkoss.zul.Listbox.onInitRender(Listbox.java:2179)
sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
java.lang.reflect.Method.invoke(Method.java:585)
org.zkoss.zk.ui.impl.EventProcessor.process0(EventProcessor.java:211)
org.zkoss.zk.ui.impl.EventProcessor.process(EventProcessor.java:143)

Of course I know what's causing the crash but I can't figure out why it isn't handled by the error page. I can't even get a breakpoint at Publish.java:208 to catch the debugger.

Thanks for any insight.

/Daryl

delete retag edit

dastultz
797 8

It turns out I needed error-page in web.xml, too. My service method is catching everything but the error is happening in an event thread so I thought the zk.xml error-page would handle it.

/Daryl

[hide preview]