Ticket #475 (closed: fixed)
Hide stack trace from user
| Reported by: | gregory | Owned by: | olle |
|---|---|---|---|
| Milestone: | Proteios SE 2.7 | Keywords: | |
| Cc: |
Description
Stacktraces are intimidating, hide them and let the user show it by clicking a button.
Change History
comment:1 Changed 3 years ago by fredrik
- Milestone changed from Proteios SE Future Release to Proteios SE 2.7
comment:3 Changed 3 years ago by olle
Discussion of cases where stack traces are displayed:
- Exceptions that are not caught will lead to a stack trace being displayed through JSP file www/exception.jsp in client/servlet/, in addition to an error message.
- Jobs that finish with an error might include a stack trace in the status message, even though the label "Stacktrace" might not be shown. These messages are the ones shown in the list of "Last Server Messages" displayed on the home page directly after logging in, and referenced in the comment added 2009-03-03 08:49:10 by fredrik.
- Error messages output from actions and displayed in a temporary info/error message panel at the top of the web page might also include stack traces, although this is a more seldom case. These error message are formatted by public method Tag convert(org.proteios.gui.Error err) in class/file gui/web/GUIConverter.java in client/servlet/.
Case 1 is the most well-defined, as the JSP file contains an explicit call to obtain the stack trace, exception.printStackTrace(new PrintWriter(out)). This makes it fairly simple to modify display of the stack trace. In cases 2 and 3, the stack trace is optional and might be part of a larger error message, making it hard to identify and modify the stack trace part.
comment:4 Changed 3 years ago by olle
Design of first version of support for hiding stack traces.
Modifications in the different cases where stack traces might be displayed:
- JSP file www/exception.jsp in client/servlet/ will be modified to only show the stack trace if a link named "Stacktrace" is clicked. This is accomplished by placing the stack trace in its own div tag, that is hidden by default, and couple link "Stacktrace" to JavaScript function toggle(id) in file www/static/js/script.js in client/servlet/, where the id value is set to the id of the stack trace div tag.
- The home view is modified to use a table instead of a list to show the last server messages, but only the date and message name are displayed in the table, hiding any stack traces in the message description. The name column is coupled to an action link to action ViewJob, so the full message can be inspected by clicking on the message name.
- Error messages displayed in a temporary info/error message panel at the top of the web page will not be modified, as stack traces are seldom used in these messages. However, tests show that the same method as used for case 1 above may be used to hide part of the message, by modifying public method Tag convert(org.proteios.gui.Error err) in class/file gui/web/GUIConverter.java in client/servlet/, if it should be decided to include this case in the future.
comment:5 Changed 3 years ago by olle
(In [3166]) Refs #475. First version of support for hiding stack traces from the user:
- JSP file www/exception.jsp in client/servlet/ updated to only
show the stack trace if a link named "Stacktrace" is clicked. This is accomplished by placing the stack trace in its own div tag, that is hidden by default, and couple link "Stacktrace" to JavaScript function toggle(id) in file www/static/js/script.js in client/servlet/, where the id value is set to the id of the stack trace div tag.
- Class/file action/read/ViewHome.java in client/servlet/ updated
in public method void runMe() to use a table instead of a list to show the last server messages, but only the date and message name are displayed in the table, hiding any stack traces in the message description. The name column is coupled to an action link to action class/file action/job/ViewJob.java in client/servlet/, so the full message can be inspected by clicking on the message name.
comment:6 Changed 3 years ago by olle
Tests:
The support for hiding stack traces from the user was tested using an action class, modified to give a NullPointerException directly when entered, by calling a method for a null object. Hiding/showing the stack trace was tested with successful result using web browser FireFox 3.0.7 under SuSE Linux, and Internet Explorer 7.0.5730.11 under Microsoft Windows XP Professional.
comment:7 Changed 3 years ago by olle
- severity changed from 16 to 2
Severity set to 2, since functionality in existing classes/files could be used.
comment:8 Changed 3 years ago by olle
- Status changed from assigned to closed
- Resolution set to fixed
Ticket closed as the desired functionality has been added.
comment:9 Changed 3 years ago by olle
Addendum:
In comment added 2009-03-17 13:00:39 by olle was mentioned for error messages displayed in a temporary info/error message panel at the top of the web page (case 3), that the same method as used for error messages displayed using a JSP file (case 1) might be used to hide part of the message, by modifying public method Tag convert(org.proteios.gui.Error err) in class/file gui/web/GUIConverter.java in client/servlet/. Below is a description of how this may be done, in case it should be of use in the future. Parsing of the incoming error text and its separation into a message part and a stack trace part is not covered by the description.
Current code:
public Tag convert(org.proteios.gui.Error err)
{
Tag layout = hf.newLayoutDiv().newDiv().setId("error");
layout.newCData(err.getError());
return layout.getRoot();
}
Code with show/hide link for stack trace:
public Tag convert(org.proteios.gui.Error err)
{
// TODO: Input err.getError() separated into strings 'message_str' and 'stacktrace_str'
Tag layout = hf.newLayoutDiv();
Div errorDiv = layout.newDiv();
errorDiv.setId("error").newCData(message_str);
errorDiv.newBr();
Tag href = errorDiv.newA().setHref("#");
href.setOnClick("toggle('stacktrace');");
href.newCData("Stacktrace");
errorDiv.newDiv().setId("stacktrace").setStyle("display: none").newCData(stacktrace_str);
return layout.getRoot();
}

It doesn't look good with the full job error stack trace after logging in to the demo server