Skip to content

Commit

Permalink
commons: log bugs with stack-trace and instructions
Browse files Browse the repository at this point in the history
Motivation:

The ShellApplication framework is used as the basis for the deletation
and srmfs commands (srm-client) and chimera (distributed as part of
dCache).  Currently, any bug is logged simply with as the Exception's
toString value.  This does not convey that the user found a bug, what
the user should do, or provide sufficient information to debug the
problem.

Modification:

Provide user with explicit instructions to contact us, and supply
sufficient information to make debugging possible.

Result:

We should recieve feedback on bugs with enough information to fix 'em.

Target: master
Request: 2.16
Request: 2.15
Request: 2.14
Request: 2.13
Requires-notes: yes
Requires-book: no
Patch: https://rb.dcache.org/r/9774/
Acked-by: Albert Rossi
  • Loading branch information
paulmillar committed Sep 26, 2016
1 parent f0f56bc commit 71d02ee
Showing 1 changed file with 10 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,15 @@
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.PrintStream;
import java.io.PrintWriter;
import java.io.Serializable;
import java.io.StringWriter;
import java.util.Objects;
import java.util.concurrent.Callable;

import dmg.util.CommandException;
import dmg.util.CommandExitException;
import dmg.util.CommandPanicException;
import dmg.util.CommandSyntaxException;
import dmg.util.CommandThrowableException;
import dmg.util.command.Command;
Expand Down Expand Up @@ -168,6 +171,13 @@ public void execute(Args args) throws Throwable
out = sb.toString();
} catch (CommandExitException e) {
throw e;
} catch (CommandPanicException e) {
Ansi sb = Ansi.ansi();
sb.fg(RED).a("Bug detected! ").reset().a("Please email the following details to <support@dcache.org>:\n");
Throwable t = e.getCause() == null ? e : e.getCause();
StringWriter sw = new StringWriter();
t.printStackTrace(new PrintWriter(sw));
out = sb.a(sw.toString()).toString();
} catch (Exception e) {
out = Ansi.ansi().fg(RED).a(e.getMessage()).reset().toString();
}
Expand Down

0 comments on commit 71d02ee

Please sign in to comment.