Skip to content

Commit

Permalink
Clean up the throwable wrapper
Browse files Browse the repository at this point in the history
  • Loading branch information
Konrad Dysput committed Nov 21, 2024
1 parent 915f095 commit 038cfc0
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 57 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -312,8 +312,8 @@ public void disableAnr() {

private List<BacktraceReport> transformExceptionIntoReports(Throwable exception, Map<String, Object> attributes) {
final String exceptionTrace = UUID.randomUUID().toString();
String parentId = null;
final List<BacktraceReport> reports = new ArrayList<>();
String parentId = null;

while (exception != null) {
BacktraceReport report = new BacktraceReport(exception, attributes);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,9 +54,8 @@ public void uncaughtException(final Thread thread, final Throwable throwable) {
OnServerResponseEventListener callback = getCallbackToDefaultHandler(thread, throwable);

BacktraceLogger.e(LOG_TAG, "Sending uncaught exception to Backtrace API", throwable);
Exception exception = throwable instanceof Exception ? (Exception) throwable : new UnhandledThrowableWrapper(throwable);

this.client.send(exception, customAttributes, callback);
this.client.send(throwable, customAttributes, callback);

BacktraceLogger.d(LOG_TAG, "Uncaught exception sent to Backtrace API");

Expand All @@ -68,14 +67,6 @@ public void uncaughtException(final Thread thread, final Throwable throwable) {
}
}

private Exception getCausedException(Throwable throwable) {
if (throwable instanceof Exception) {
return (Exception) throwable;
}

return new UnhandledThrowableWrapper(throwable);
}

private OnServerResponseEventListener getCallbackToDefaultHandler(final Thread thread, final Throwable throwable) {
return backtraceResult -> {
BacktraceLogger.d(LOG_TAG, "Root handler event callback");
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
import backtraceio.library.models.BacktraceData;
import backtraceio.library.models.BacktraceStackFrame;
import backtraceio.library.models.BacktraceStackTrace;
import backtraceio.library.models.UnhandledThrowableWrapper;

/**
* Captured application error
Expand Down Expand Up @@ -175,12 +174,12 @@ public BacktraceReport(Throwable throwable, Map<String, Object> attributes, List
this.attributes = CollectionUtils.copyMap(attributes);
this.attachmentPaths = CollectionUtils.copyList(attachmentPaths);
this.exception = this.prepareException(throwable);
if (throwable != null) {
this.classifier = getExceptionClassifier(throwable);
}
this.exceptionTypeReport = exception != null;
this.diagnosticStack = new BacktraceStackTrace(exception).getStackFrames();

if (this.exceptionTypeReport && exception != null) {
this.classifier = getExceptionClassifier(exception);
}
this.setDefaultErrorTypeAttribute();
}

Expand All @@ -202,10 +201,7 @@ public static Map<String, Object> concatAttributes(
return reportAttributes;
}

public String getExceptionClassifier(Exception exception) {
if (exception instanceof UnhandledThrowableWrapper) {
return ((UnhandledThrowableWrapper) exception).getClassifier();
}
public String getExceptionClassifier(Throwable exception) {
return exception.getClass().getCanonicalName();
}

Expand Down

0 comments on commit 038cfc0

Please sign in to comment.