https://github.com/dbeaudoinfortin/stacktracecompactor
Make your Java stack traces less verbose!
https://github.com/dbeaudoinfortin/stacktracecompactor
exceptions java java-stacktraces minify minify-java stack-traces stacktrace
Last synced: 9 months ago
JSON representation
Make your Java stack traces less verbose!
- Host: GitHub
- URL: https://github.com/dbeaudoinfortin/stacktracecompactor
- Owner: dbeaudoinfortin
- License: mit
- Created: 2024-07-06T13:27:24.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2025-02-27T15:53:29.000Z (about 1 year ago)
- Last Synced: 2025-02-27T22:27:51.836Z (about 1 year ago)
- Topics: exceptions, java, java-stacktraces, minify, minify-java, stack-traces, stacktrace
- Language: Java
- Homepage:
- Size: 656 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# StackTraceCompactor 
World's most advanced stack trace generator! 😃 Make your Java stack traces less verbose without sacrificing information!

A 50% reduction.
## How to use
Add the following to your pom.xml:
```xml
io.github.dbeaudoinfortin
stack-trace-compactor
0.0.5
```
And invoke the utility by calling `StackTraceCompactor.getCompactStackTrace(t)` :
```java
try {
//Some fun stuff
} catch (Throwable t) {
log.error("Unexpected failure.\n" + StackTraceCompactor.getCompactStackTrace(t));
}
```
## How it works
The stack elements are first generated using the Apache Commons Lang3 library. This produces a reversed order to the exception chain that shows the root cause at the very top. Then the following redundant information is removed:
- As per Java convention, class names and file names should always be the same. When they are, I omit the file name and only retain the line number.
- Portions of the package name that have already been stated in the previous line are abbreviated on subsequent lines.
- Inner classes are treated similarly to the package name and are also condensed.
- Exception messages are often duplicated when an exception is wrapped one or multiple times. When this happens, I omit the redundant information.
- When dealing with wrapped exceptions, common (duplicated) stack frames are omitted.
## Requirements
- Requires Java 8 or later.
- If you want to build the jar from the source code you will need [Apache Maven](https://maven.apache.org/).
## Legal Stuff
Copyright (c) 2024 David Fortin
This software is provided by David Fortin under the MIT License, meaning you are free to use it however you want, as long as you include the original copyright notice (above) and license notice in any copy you make. You just can't hold me liable in case something goes wrong. License details can be read [here](https://github.com/dbeaudoinfortin/StackTraceCompactor?tab=MIT-1-ov-file)