Skip to content

Commit

Permalink
#3747: shorter
Browse files Browse the repository at this point in the history
  • Loading branch information
yegor256 committed Dec 24, 2024
1 parent eeb636e commit 1f0f8d0
Showing 1 changed file with 16 additions and 2 deletions.
18 changes: 16 additions & 2 deletions eo-runtime/src/main/java/org/eolang/PhSafe.java
Original file line number Diff line number Diff line change
Expand Up @@ -220,17 +220,31 @@ private static List<String> trace(final Throwable exp, final String head) {
trace.add(
String.format(
"%s#%s():%d",
elm.getClassName().replaceAll("([a-zA-Z])[^.]*\\.", "$1."),
PhSafe.shorter(elm.getClassName()),
elm.getMethodName(),
elm.getLineNumber()
)
);
}
}
trace.add(String.format("%s (%s)", head, exp.getClass().getName()));
trace.add(
String.format(
"%s (%s)",
head, PhSafe.shorter(exp.getClass().getName())
)
);
return trace;
}

/**
* Make class name shorter.
* @param full The full name of class
* @return Shorter name
*/
private static String shorter(final String full) {
return full.replaceAll("(.)[^.]*\\.", "$1.");
}

/**
* The label of the exception.
* @param suffix The suffix to add to the label
Expand Down

0 comments on commit 1f0f8d0

Please sign in to comment.