debug library

This commit is contained in:
Zadat Olayinka
2021-04-05 08:31:51 +01:00
parent a41a372223
commit 7287c2079d
2 changed files with 13 additions and 7 deletions

View File

@@ -135,9 +135,9 @@ public class FyipeTracker {
// send to the server
return this.sendErrorEventToServer();
}
public JsonObject captureException(Throwable throwable) throws IOException {
public JsonObject captureException(Exception exception) throws IOException {
// construct the error object
StackTrace formattedStackTrace = this.util.getExceptionStackTrace(throwable);
StackTrace formattedStackTrace = this.util.getExceptionStackTrace(exception);
// set the a handled tag
this.setTag(new Tag("handled", "true"));
@@ -152,8 +152,10 @@ public class FyipeTracker {
new Thread.UncaughtExceptionHandler() {
@Override
public void uncaughtException(Thread t, Throwable e) {
System.out.println("listener");
System.out.println(e);
try {
captureException(e);
captureException((Exception) e);
} catch (IOException ioException) {
ioException.printStackTrace();
}
@@ -203,8 +205,8 @@ public class FyipeTracker {
FyipeTransport apiTransport = new FyipeTransport(this.apiUrl);
String errorEventBody = ParameterStringBuilder.getErrorEventRequestString(this.getCurrentEvent());
JsonObject response = apiTransport.sendErrorEventToServer(errorEventBody);
// generate a new event Id
this.setEventId();
// clear the timeline after a successful call to the server
this.clear(this.getEventId());

View File

@@ -33,9 +33,13 @@ public class Util {
UUID uuid = UUID.randomUUID();
return uuid.toString();
}
public StackTrace getExceptionStackTrace(Throwable throwable) {
String message = throwable.getMessage();
StackTraceElement[] stackTraceElement = throwable.getStackTrace();
public StackTrace getExceptionStackTrace(Exception exception) {
System.out.println("getExceptionStackTrace");
System.out.println(exception);
String message = exception.getMessage();
StackTraceElement[] stackTraceElement = exception.getStackTrace();
System.out.println("Stack Trace");
System.out.println(stackTraceElement);
int lineNumber = stackTraceElement[0].getLineNumber();
String fileName = stackTraceElement[0].getFileName();