File tree Expand file tree Collapse file tree 2 files changed +11
-21
lines changed
Expand file tree Collapse file tree 2 files changed +11
-21
lines changed Original file line number Diff line number Diff line change 2121import com .lambda .config .AbstractSetting ;
2222import com .lambda .module .Module ;
2323import com .lambda .module .ModuleRegistry ;
24- import com .lambda .util .DynamicException ;
24+ import com .lambda .util .DynamicExceptionKt ;
2525import com .llamalad7 .mixinextras .injector .wrapmethod .WrapMethod ;
2626import com .llamalad7 .mixinextras .injector .wrapoperation .Operation ;
2727import net .minecraft .client .MinecraftClient ;
@@ -47,7 +47,7 @@ public class CrashReportMixin {
4747 @ Inject (method = "<init>(Ljava/lang/String;Ljava/lang/Throwable;)V" , at = @ At ("TAIL" ))
4848 void injectConstructor (String message , Throwable cause , CallbackInfo ci ) {
4949 if (!Lambda .INSTANCE .isDebug () && MinecraftClient .getInstance () != null ) {
50- this .cause = new DynamicException (cause );
50+ this .cause = DynamicExceptionKt . dynamicException (cause );
5151 }
5252 }
5353
Original file line number Diff line number Diff line change 1818package com.lambda.util
1919
2020import com.lambda.util.DynamicReflectionSerializer.simpleRemappedName
21- import java.io.PrintStream
22- import java.io.PrintWriter
21+ import kotlin.collections.toTypedArray
2322
24- class DynamicException (original : Throwable ) : Throwable(original) {
25- private fun Array<StackTraceElement>.remapClassNames () =
26- map { element ->
23+ /* *
24+ * Remaps the stacktrace in production to have readable, class, method and field names
25+ */
26+ fun dynamicException (original : Throwable ) = Throwable (original.localizedMessage)
27+ .apply {
28+ stackTrace = stackTrace.map { element ->
2729 StackTraceElement (
2830 element.className.simpleRemappedName,
2931 element.methodName.simpleRemappedName,
30- element.fileName,
32+ element.fileName, // This is intentional, you don't need to remap the file name so might as well keep a reference of the class file name
3133 element.lineNumber
3234 )
3335 }.toTypedArray()
34-
35- override fun printStackTrace (s : PrintStream ) =
36- stackTrace.forEach { s.println (" \t at $it " ) }
37-
38- override fun printStackTrace (s : PrintWriter ) =
39- stackTrace.forEach { s.println (" \t at $it " ) }
40-
41- override fun toString (): String = localizedMessage
42-
43- init {
44- stackTrace = stackTrace.remapClassNames()
45- }
46- }
36+ }
You can’t perform that action at this time.
0 commit comments