@Test public void testBuildErrorReport() throws Exception { InputStream is = ExceptionHandlerTest.class.getResourceAsStream("/fixtures/error_reporting/test-multibit-hd.log"); String truncatedLog = ExceptionHandler.readAndTruncateInputStream(is, 4096); ErrorReport testObject = ExceptionHandler.buildErrorReport( "Example notes", truncatedLog ); assertThat(testObject.getLogEntries()).isNotEmpty(); assertThat(testObject.getLogEntries().size()).isEqualTo(11); assertThat(testObject.getLogEntries().get(8).getStackTrace()).contains("java.io.IOException"); }
static ErrorReport buildErrorReport(String userNotes, String truncatedCurrentLog) { java.util.List<ErrorReportLogEntry> errorReportLogEntryList = Lists.newArrayList(); final Scanner scanner = new Scanner(truncatedCurrentLog); while (scanner.hasNextLine()) { String logEntry = scanner.nextLine(); Optional<ErrorReportLogEntry> entry = Json.readJson( logEntry.getBytes(Charsets.UTF_8), ErrorReportLogEntry.class ); if (entry.isPresent()) { errorReportLogEntryList.add(entry.get()); } } ErrorReport errorReport = new ErrorReport(); errorReport.setOsName(OSUtils.getOsName()); errorReport.setOsVersion(OSUtils.getOsVersion()); errorReport.setOsArch(OSUtils.is64Bit() ? "64" : "32"); errorReport.setAppVersion(Configurations.currentConfiguration.getCurrentVersion()); errorReport.setUserNotes(userNotes); errorReport.setLogEntries(errorReportLogEntryList); return errorReport; }
ExceptionHandler extends EventQueue implements Thread.UncaughtExceptionHandler { static ErrorReport buildErrorReport(String userNotes, String truncatedCurrentLog) { java.util.List<ErrorReportLogEntry> errorReportLogEntryList = Lists.newArrayList(); final Scanner scanner = new Scanner(truncatedCurrentLog); while (scanner.hasNextLine()) { String logEntry = scanner.nextLine(); Optional<ErrorReportLogEntry> entry = Json.readJson( logEntry.getBytes(Charsets.UTF_8), ErrorReportLogEntry.class ); if (entry.isPresent()) { errorReportLogEntryList.add(entry.get()); } } ErrorReport errorReport = new ErrorReport(); errorReport.setOsName(OSUtils.getOsName()); errorReport.setOsVersion(OSUtils.getOsVersion()); errorReport.setOsArch(OSUtils.is64Bit() ? "64" : "32"); errorReport.setAppVersion(Configurations.currentConfiguration.getCurrentVersion()); errorReport.setUserNotes(userNotes); errorReport.setLogEntries(errorReportLogEntryList); return errorReport; } }
ExceptionHandler extends EventQueue implements Thread.UncaughtExceptionHandler { static ErrorReport buildErrorReport(String userNotes, String truncatedCurrentLog) { java.util.List<ErrorReportLogEntry> errorReportLogEntryList = Lists.newArrayList(); final Scanner scanner = new Scanner(truncatedCurrentLog); while (scanner.hasNextLine()) { String logEntry = scanner.nextLine(); Optional<ErrorReportLogEntry> entry = Json.readJson( logEntry.getBytes(Charsets.UTF_8), ErrorReportLogEntry.class ); if (entry.isPresent()) { errorReportLogEntryList.add(entry.get()); } } ErrorReport errorReport = new ErrorReport(); errorReport.setOsName(OSUtils.getOsName()); errorReport.setOsVersion(OSUtils.getOsVersion()); errorReport.setOsArch(OSUtils.is64Bit() ? "64" : "32"); errorReport.setAppVersion(Configurations.currentConfiguration.getCurrentVersion()); errorReport.setUserNotes(userNotes); errorReport.setLogEntries(errorReportLogEntryList); return errorReport; }  }
ExceptionHandler extends EventQueue implements Thread.UncaughtExceptionHandler { static ErrorReport buildErrorReport(String userNotes, String truncatedCurrentLog) { java.util.List<ErrorReportLogEntry> errorReportLogEntryList = Lists.newArrayList(); final Scanner scanner = new Scanner(truncatedCurrentLog); while (scanner.hasNextLine()) { String logEntry = scanner.nextLine(); Optional<ErrorReportLogEntry> entry = Json.readJson( logEntry.getBytes(Charsets.UTF_8), ErrorReportLogEntry.class ); if (entry.isPresent()) { errorReportLogEntryList.add(entry.get()); } } ErrorReport errorReport = new ErrorReport(); errorReport.setOsName(OSUtils.getOsName()); errorReport.setOsVersion(OSUtils.getOsVersion()); errorReport.setOsArch(OSUtils.is64Bit() ? "64" : "32"); errorReport.setAppVersion(Configurations.currentConfiguration.getCurrentVersion()); errorReport.setUserNotes(userNotes); errorReport.setLogEntries(errorReportLogEntryList); return errorReport; }  static void registerExceptionHandler(); @SuppressWarnings("unchecked") static void handleThrowable(Throwable t); @SuppressWarnings("unchecked") static void handleManualErrorReport(); @Override void uncaughtException(Thread t, Throwable e); static SubscriberExceptionHandler newSubscriberExceptionHandler(); static String readAndTruncateInputStream(InputStream inputStream, int maxLength); static ErrorReportResult handleErrorReportUpload(String userNotes, URL errorReportingUrl); }
ExceptionHandler extends EventQueue implements Thread.UncaughtExceptionHandler { static ErrorReport buildErrorReport(String userNotes, String truncatedCurrentLog) { java.util.List<ErrorReportLogEntry> errorReportLogEntryList = Lists.newArrayList(); final Scanner scanner = new Scanner(truncatedCurrentLog); while (scanner.hasNextLine()) { String logEntry = scanner.nextLine(); Optional<ErrorReportLogEntry> entry = Json.readJson( logEntry.getBytes(Charsets.UTF_8), ErrorReportLogEntry.class ); if (entry.isPresent()) { errorReportLogEntryList.add(entry.get()); } } ErrorReport errorReport = new ErrorReport(); errorReport.setOsName(OSUtils.getOsName()); errorReport.setOsVersion(OSUtils.getOsVersion()); errorReport.setOsArch(OSUtils.is64Bit() ? "64" : "32"); errorReport.setAppVersion(Configurations.currentConfiguration.getCurrentVersion()); errorReport.setUserNotes(userNotes); errorReport.setLogEntries(errorReportLogEntryList); return errorReport; }  static void registerExceptionHandler(); @SuppressWarnings("unchecked") static void handleThrowable(Throwable t); @SuppressWarnings("unchecked") static void handleManualErrorReport(); @Override void uncaughtException(Thread t, Throwable e); static SubscriberExceptionHandler newSubscriberExceptionHandler(); static String readAndTruncateInputStream(InputStream inputStream, int maxLength); static ErrorReportResult handleErrorReportUpload(String userNotes, URL errorReportingUrl); static final String LIVE_ERROR_REPORTING_URL; }