@Test public void saveWrapperSdkCrashFailsWithIOException() throws IOException, JSONException { doThrow(new IOException()).when(FileManager.class); FileManager.write(any(File.class), anyString()); LogSerializer logSerializer = Mockito.mock(LogSerializer.class); when(logSerializer.serializeLog(any(ManagedErrorLog.class))).thenReturn("mock"); Crashes.getInstance().setLogSerializer(logSerializer); String data = "d"; WrapperSdkExceptionManager.saveWrapperException(Thread.currentThread(), null, new Exception(), data); verifyStatic(); AppCenterLog.error(anyString(), anyString(), argThat(new ArgumentMatcher<Throwable>() { @Override public boolean matches(Object argument) { return argument instanceof IOException; } })); data = "e"; WrapperSdkExceptionManager.saveWrapperException(Thread.currentThread(), null, new Exception(), data); verifyStatic(); AppCenterLog.error(anyString(), anyString(), argThat(new ArgumentMatcher<Throwable>() { @Override public boolean matches(Object argument) { return argument instanceof IOException; } })); }
public static UUID saveWrapperException(Thread thread, Throwable throwable, com.microsoft.appcenter.crashes.ingestion.models.Exception modelException, String rawSerializedException) { try { UUID errorId = Crashes.getInstance().saveUncaughtException(thread, throwable, modelException); if (errorId != null && rawSerializedException != null) { sWrapperExceptionDataContainer.put(errorId.toString(), rawSerializedException); File dataFile = getFile(errorId); FileManager.write(dataFile, rawSerializedException); AppCenterLog.debug(LOG_TAG, "Saved raw wrapper exception data into " + dataFile); } return errorId; } catch (Exception e) { AppCenterLog.error(LOG_TAG, "Failed to save wrapper exception data to file", e); return null; } }
WrapperSdkExceptionManager { public static UUID saveWrapperException(Thread thread, Throwable throwable, com.microsoft.appcenter.crashes.ingestion.models.Exception modelException, String rawSerializedException) { try { UUID errorId = Crashes.getInstance().saveUncaughtException(thread, throwable, modelException); if (errorId != null && rawSerializedException != null) { sWrapperExceptionDataContainer.put(errorId.toString(), rawSerializedException); File dataFile = getFile(errorId); FileManager.write(dataFile, rawSerializedException); AppCenterLog.debug(LOG_TAG, "Saved raw wrapper exception data into " + dataFile); } return errorId; } catch (Exception e) { AppCenterLog.error(LOG_TAG, "Failed to save wrapper exception data to file", e); return null; } } }
WrapperSdkExceptionManager { public static UUID saveWrapperException(Thread thread, Throwable throwable, com.microsoft.appcenter.crashes.ingestion.models.Exception modelException, String rawSerializedException) { try { UUID errorId = Crashes.getInstance().saveUncaughtException(thread, throwable, modelException); if (errorId != null && rawSerializedException != null) { sWrapperExceptionDataContainer.put(errorId.toString(), rawSerializedException); File dataFile = getFile(errorId); FileManager.write(dataFile, rawSerializedException); AppCenterLog.debug(LOG_TAG, "Saved raw wrapper exception data into " + dataFile); } return errorId; } catch (Exception e) { AppCenterLog.error(LOG_TAG, "Failed to save wrapper exception data to file", e); return null; } } @VisibleForTesting  WrapperSdkExceptionManager(); }
WrapperSdkExceptionManager { public static UUID saveWrapperException(Thread thread, Throwable throwable, com.microsoft.appcenter.crashes.ingestion.models.Exception modelException, String rawSerializedException) { try { UUID errorId = Crashes.getInstance().saveUncaughtException(thread, throwable, modelException); if (errorId != null && rawSerializedException != null) { sWrapperExceptionDataContainer.put(errorId.toString(), rawSerializedException); File dataFile = getFile(errorId); FileManager.write(dataFile, rawSerializedException); AppCenterLog.debug(LOG_TAG, "Saved raw wrapper exception data into " + dataFile); } return errorId; } catch (Exception e) { AppCenterLog.error(LOG_TAG, "Failed to save wrapper exception data to file", e); return null; } } @VisibleForTesting  WrapperSdkExceptionManager(); static UUID saveWrapperException(Thread thread, Throwable throwable, com.microsoft.appcenter.crashes.ingestion.models.Exception modelException, String rawSerializedException); static void deleteWrapperExceptionData(UUID errorId); static String loadWrapperExceptionData(UUID errorId); static String trackException(com.microsoft.appcenter.crashes.ingestion.models.Exception modelException, Map<String, String> properties, Iterable<ErrorAttachmentLog> attachments); static void setAutomaticProcessing(@SuppressWarnings("SameParameterValue") boolean automaticProcessing); static AppCenterFuture<Collection<ErrorReport>> getUnprocessedErrorReports(); static AppCenterFuture<Boolean> sendCrashReportsOrAwaitUserConfirmation(Collection<String> filteredReportIds); static ErrorReport buildHandledErrorReport(Context context, String errorReportId); static void sendErrorAttachments(String errorReportId, Iterable<ErrorAttachmentLog> attachments); }
WrapperSdkExceptionManager { public static UUID saveWrapperException(Thread thread, Throwable throwable, com.microsoft.appcenter.crashes.ingestion.models.Exception modelException, String rawSerializedException) { try { UUID errorId = Crashes.getInstance().saveUncaughtException(thread, throwable, modelException); if (errorId != null && rawSerializedException != null) { sWrapperExceptionDataContainer.put(errorId.toString(), rawSerializedException); File dataFile = getFile(errorId); FileManager.write(dataFile, rawSerializedException); AppCenterLog.debug(LOG_TAG, "Saved raw wrapper exception data into " + dataFile); } return errorId; } catch (Exception e) { AppCenterLog.error(LOG_TAG, "Failed to save wrapper exception data to file", e); return null; } } @VisibleForTesting  WrapperSdkExceptionManager(); static UUID saveWrapperException(Thread thread, Throwable throwable, com.microsoft.appcenter.crashes.ingestion.models.Exception modelException, String rawSerializedException); static void deleteWrapperExceptionData(UUID errorId); static String loadWrapperExceptionData(UUID errorId); static String trackException(com.microsoft.appcenter.crashes.ingestion.models.Exception modelException, Map<String, String> properties, Iterable<ErrorAttachmentLog> attachments); static void setAutomaticProcessing(@SuppressWarnings("SameParameterValue") boolean automaticProcessing); static AppCenterFuture<Collection<ErrorReport>> getUnprocessedErrorReports(); static AppCenterFuture<Boolean> sendCrashReportsOrAwaitUserConfirmation(Collection<String> filteredReportIds); static ErrorReport buildHandledErrorReport(Context context, String errorReportId); static void sendErrorAttachments(String errorReportId, Iterable<ErrorAttachmentLog> attachments);  }