Пример #1
0
 public void testExtractRootCauseErrorStatusWithException() throws Exception {
   IStatus status =
       extractRootCause(new Status(IStatus.ERROR, "id1", "Test", new IOException("IO")));
   assertNotNull(status);
   assertEquals("id1", status.getPlugin());
   assertEquals("Test", status.getMessage());
   assertEquals("IO", status.getException().getMessage());
 }
Пример #2
0
  public void testExtractRootCauseFromNestedMultiStatus() throws Exception {
    MultiStatus multiStatus =
        new MultiStatus("id0", 0, "Message", new FileNotFoundException("FNFE"));
    Status status1 = new Status(IStatus.WARNING, "id1", "Test", new IOException("IO"));
    Status status2 = new Status(IStatus.ERROR, "id2", "Test", new IOException("IO"));
    Status status3 = new Status(IStatus.ERROR, "id3", "Test", null);
    multiStatus.add(status1);
    multiStatus.add(status2);
    multiStatus.add(status3);

    IStatus status = extractRootCause(multiStatus);
    assertNotNull(status);
    assertEquals("id2", status.getPlugin());
  }
 /**
  * Add this exception to the collector. If a log was specified in the constructor then the
  * exception will be output to the log. You can retreive exceptions using <code>getStatus</code>.
  *
  * @param exception the exception to collect
  */
 public void handleException(CoreException exception) {
   // log the exception if we have a log
   if (log != null) {
     log.log(new Status(severity, pluginId, 0, message, exception));
   }
   // Record each status individually to flatten the resulting multi-status
   IStatus exceptionStatus = exception.getStatus();
   // Wrap the exception so the stack trace is not lost.
   IStatus status =
       new Status(
           exceptionStatus.getSeverity(),
           exceptionStatus.getPlugin(),
           exceptionStatus.getCode(),
           exceptionStatus.getMessage(),
           exception);
   recordStatus(status);
   IStatus[] children = status.getChildren();
   for (int i = 0; i < children.length; i++) {
     IStatus status2 = children[i];
     recordStatus(status2);
   }
 }