private void writeToFile(@Nonnull String stackTrace, @Nonnull String fileName) { try { BufferedWriter bos = null; try { bos = new BufferedWriter(new FileWriter(localPath + "/" + fileName)); bos.write(stackTrace); bos.flush(); } finally { if (bos != null) { bos.close(); } } } catch (Exception e) { // unable to save to the file - strange Log.e(TAG, Strings.fromStackTrace(e.getStackTrace())); } }
public void uncaughtException(Thread t, Throwable e) { try { final Date time = new Date(); final String stackTrace = getStackTrace(e); if (stackTrace != null) { if (localPath != null) { writeToFile(stackTrace, String.valueOf(time.getTime()) + ".stacktrace"); } if (url != null) { sendToServer(stackTrace, time); } } } catch (Throwable anyException) { Log.e(TAG, Strings.fromStackTrace(anyException.getStackTrace())); } finally { defaultUEH.uncaughtException(t, e); } }