Skip to content

Commit

Permalink
Simplify logReportMsg
Browse files Browse the repository at this point in the history
  • Loading branch information
mrbuilder1961 committed Jan 19, 2025
1 parent 30b3be9 commit f2f7e10
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions src/main/java/obro1961/chatpatches/ChatPatches.java
Original file line number Diff line number Diff line change
Expand Up @@ -75,18 +75,19 @@ public void onInitializeClient() {
* <p>Outputs the following message:
* <pre>
* [$class.$method] /!\ Please report this error on GitHub or Discord with the full log file attached! /!\
* (error)
* $error
* </pre>
*/
public static <X extends Throwable> void logReportMsg(@NotNull X error) {
public static void logReportMsg(@NotNull Throwable error) {
StackWalker walker = StackWalker.getInstance(StackWalker.Option.RETAIN_CLASS_REFERENCE);
String clazz = walker.getCallerClass().getSimpleName();
String method = walker.walk(frames -> frames.skip(1).findFirst().orElseThrow().getMethodName());

if(method.isBlank())
method = error.getStackTrace()[0].getMethodName();

LOGGER.error("[%s.%s] /!\\ Please report this error on GitHub or Discord with the full log file attached! /!\\".formatted(clazz, method), error);
//noinspection StringConcatenationArgumentToLogCall: it's whining but it's totally fine
LOGGER.error("[" + clazz + "." + method + "] /!\\ Please report this error on GitHub or Discord with the full log file attached! /!\\", error);
}

/**
Expand Down

0 comments on commit f2f7e10

Please sign in to comment.