2014-10-22 16:38:44 +00:00
|
|
|
package eu.siacs.conversations.utils;
|
|
|
|
|
2015-07-20 12:26:29 +00:00
|
|
|
import android.content.Context;
|
|
|
|
|
2014-10-22 16:38:44 +00:00
|
|
|
import java.io.PrintWriter;
|
|
|
|
import java.io.StringWriter;
|
|
|
|
import java.io.Writer;
|
|
|
|
import java.lang.Thread.UncaughtExceptionHandler;
|
|
|
|
|
|
|
|
public class ExceptionHandler implements UncaughtExceptionHandler {
|
|
|
|
|
|
|
|
private UncaughtExceptionHandler defaultHandler;
|
|
|
|
private Context context;
|
|
|
|
|
|
|
|
public ExceptionHandler(Context context) {
|
|
|
|
this.context = context;
|
|
|
|
this.defaultHandler = Thread.getDefaultUncaughtExceptionHandler();
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void uncaughtException(Thread thread, Throwable ex) {
|
|
|
|
Writer result = new StringWriter();
|
|
|
|
PrintWriter printWriter = new PrintWriter(result);
|
|
|
|
ex.printStackTrace(printWriter);
|
|
|
|
String stacktrace = result.toString();
|
|
|
|
printWriter.close();
|
2016-05-21 06:54:29 +00:00
|
|
|
ExceptionHelper.writeToStacktraceFile(context, stacktrace);
|
2014-10-22 16:38:44 +00:00
|
|
|
this.defaultHandler.uncaughtException(thread, ex);
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|