Improved information showed when some runtime error happens.

FEA: ItEr74S04BugFixing
This commit is contained in:
Manuel Rego Casasnovas 2011-04-13 18:21:51 +02:00
parent a7e49fe176
commit dbe6e5e828
3 changed files with 79 additions and 28 deletions

View file

@ -21,14 +21,18 @@
package org.navalplanner.web.error;
import java.io.PrintWriter;
import java.io.StringWriter;
import java.io.Writer;
import javax.servlet.http.HttpServletRequest;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.navalplanner.web.common.components.I18n;
import org.zkoss.zk.ui.Component;
import org.zkoss.zk.ui.Executions;
import org.zkoss.zk.ui.util.GenericForwardComposer;
import org.zkoss.zul.api.Textbox;
public class PageForErrorOnEvent extends GenericForwardComposer {
@ -36,15 +40,13 @@ public class PageForErrorOnEvent extends GenericForwardComposer {
private Component modalWindow;
private Textbox stacktrace;
@Override
public void doAfterCompose(Component comp) throws Exception {
super.doAfterCompose(comp);
logError();
modalWindow = comp;
I18n i18NMessge = (I18n) modalWindow.getFellowIfAny("message");
if (i18NMessge != null) {
i18NMessge.forceLoad();
}
stacktrace.setValue(getStacktrace());
}
private void logError() {
@ -70,4 +72,12 @@ public class PageForErrorOnEvent extends GenericForwardComposer {
Executions.sendRedirect("/");
}
private String getStacktrace() {
Throwable exception = (Throwable) Executions.getCurrent().getAttribute(
"javax.servlet.error.exception");
Writer stacktrace = new StringWriter();
exception.printStackTrace(new PrintWriter(stacktrace));
return stacktrace.toString();
}
}

View file

@ -18,24 +18,44 @@
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
-->
<?page title="${i18n:_('NavalPlan: Error')}" ?>
<?page title="${i18n:_('NavalPlan: Runtime Error')}" ?>
<?init class="org.zkoss.zk.ui.util.Composition" arg0="/common/layout/template.zul"?>
<?link rel="stylesheet" type="text/css" href="/common/css/navalplan.css"?>
<?link rel="stylesheet" type="text/css" href="/common/css/navalplan_zk.css"?>
<zk>
<window self="@{define(content)}" >
<!--caption>
Erro ${requestScope['javax.servlet.error.status_code']}
</caption-->
<vbox apply="org.navalplanner.web.error.PageForErrorOnEvent"
sclass="errorbox">
<i18n id="message"
value="Run-time error: {0} . Error was registered and it will be fixed as soon as possible." arg0="${requestScope['javax.servlet.error.message']}" />
<hbox style="margin-left:auto; margin-right:auto">
<button id="reload" label="${i18n:_('Reload')}" />
<button id="quitSession" label="${i18n:_('Exit session')}"></button>
</hbox>
sclass="errorbox" width="800px">
<panel title="${i18n:__('Message - {0}', requestScope['javax.servlet.error.message'])}"
border="normal" style="overflow:auto">
<panelchildren>
<grid width="700px">
<columns>
<column width="100px" />
<column />
</columns>
<rows>
<row>
<label value="${i18n:_('Exception type:')}" />
<label value="${requestScope['javax.servlet.error.exception_type']}" />
</row>
<row>
<label value="${i18n:_('Status code:')}" />
<label value="${requestScope['javax.servlet.error.status_code']}" />
</row>
<row>
<label value="${i18n:_('Stacktracke:')}" />
<textbox id="stacktrace" rows="20" width="600px" />
</row>
</rows>
</grid>
<hbox style="margin-left:auto; margin-right:auto">
<button id="reload" label="${i18n:_('Reload')}" />
<button id="quitSession" label="${i18n:_('Exit session')}"></button>
</hbox>
</panelchildren>
</panel>
</vbox>
</window>
</zk>

View file

@ -19,16 +19,37 @@
along with this program. If not, see <http://www.gnu.org/licenses/>.
-->
<window title="${i18n:__('Error', requestScope['javax.servlet.error.status_code'])}"
width="400px" border="normal" mode="modal"
<window title="${i18n:_('NavalPlan: Runtime Error')}"
width="800px" border="normal" mode="modal"
apply="org.navalplanner.web.error.PageForErrorOnEvent">
<vbox>
<i18n id="message"
value="Run-time error: {0} . Error was registered and it will be fixed as soon as possible." arg0="${requestScope['javax.servlet.error.message']}" />
<hbox style="margin-left:auto; margin-right:auto">
<button id="continueWorking" label="${i18n:_('Continue')}" />
<button id="reload" label="${i18n:_('Reload')}" />
<button id="quitSession" label="${i18n:_('Exit session')}"></button>
</hbox>
</vbox>
<panel title="${i18n:__('Message - {0}', requestScope['javax.servlet.error.message'])}"
border="normal" style="overflow:auto">
<panelchildren>
<grid width="700px">
<columns>
<column width="100px" />
<column />
</columns>
<rows>
<row>
<label value="${i18n:_('Exception type:')}" />
<label value="${requestScope['javax.servlet.error.exception_type']}" />
</row>
<row>
<label value="${i18n:_('Status code:')}" />
<label value="${requestScope['javax.servlet.error.status_code']}" />
</row>
<row>
<label value="${i18n:_('Stacktracke:')}" />
<textbox id="stacktrace" rows="20" width="600px" />
</row>
</rows>
</grid>
<hbox style="margin-left:auto; margin-right:auto">
<button id="continueWorking" label="${i18n:_('Continue')}" />
<button id="reload" label="${i18n:_('Reload')}" />
<button id="quitSession" label="${i18n:_('Exit session')}"></button>
</hbox>
</panelchildren>
</panel>
</window>