Java Code Examples for com.intellij.openapi.diagnostic.IdeaLoggingEvent#getThrowable()

The following examples show how to use com.intellij.openapi.diagnostic.IdeaLoggingEvent#getThrowable() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: RollbarErrorReportSubmitter.java    From bamboo-soy with Apache License 2.0 6 votes vote down vote up
private void log(@NotNull IdeaLoggingEvent[] events, @Nullable String additionalInfo) {
  IdeaLoggingEvent ideaEvent = events[0];
  if (ideaEvent.getThrowable() == null) {
    return;
  }
  LinkedHashMap<String, Object> customData = new LinkedHashMap<>();
  customData.put(TAG_PLATFORM_VERSION, ApplicationInfo.getInstance().getBuild().asString());
  customData.put(TAG_OS, SystemInfo.OS_NAME);
  customData.put(TAG_OS_VERSION, SystemInfo.OS_VERSION);
  customData.put(TAG_OS_ARCH, SystemInfo.OS_ARCH);
  customData.put(TAG_JAVA_VERSION, SystemInfo.JAVA_VERSION);
  customData.put(TAG_JAVA_RUNTIME_VERSION, SystemInfo.JAVA_RUNTIME_VERSION);
  if (additionalInfo != null) {
    customData.put(EXTRA_ADDITIONAL_INFO, additionalInfo);
  }
  if (events.length > 1) {
    customData.put(EXTRA_MORE_EVENTS,
        Stream.of(events).map(Object::toString).collect(Collectors.joining("\n")));
  }
  rollbar.codeVersion(getPluginVersion()).log(ideaEvent.getThrowable(), customData);
}
 
Example 2
Source File: DefaultIdeaErrorLogger.java    From consulo with Apache License 2.0 6 votes vote down vote up
public void handle(IdeaLoggingEvent event) {
  if (ourLoggerBroken) return;

  try {
    Throwable throwable = event.getThrowable();
    final MemoryKind kind = getOOMErrorKind(throwable);
    if (kind != null) {
      ourOomOccurred = true;
      SwingUtilities.invokeAndWait(() -> new OutOfMemoryDialog(kind).show());
    }
    else if (throwable instanceof MappingFailedException) {
      processMappingFailed(event);
    }
    else if (!ourOomOccurred) {
      MessagePool messagePool = MessagePool.getInstance();
      messagePool.addIdeFatalMessage(event);
    }
  }
  catch (Throwable e) {
    String message = e.getMessage();
    //noinspection InstanceofCatchParameter
    if (message != null && message.contains("Could not initialize class com.intellij.diagnostic.MessagePool") || e instanceof NullPointerException && ApplicationManager.getApplication() == null) {
      ourLoggerBroken = true;
    }
  }
}
 
Example 3
Source File: LogMessage.java    From consulo with Apache License 2.0 6 votes vote down vote up
public LogMessage(IdeaLoggingEvent aEvent) {
  super();

  myThrowable = aEvent.getThrowable();

  if (StringUtil.isNotEmpty(aEvent.getMessage())) {
    myHeader = aEvent.getMessage();
  }

  if (myThrowable != null && StringUtil.isNotEmpty(myThrowable.getMessage())) {
    if (!myHeader.equals(NO_MESSAGE)) {
      if (!myHeader.endsWith(": ") && !myHeader.endsWith(":")) {
        myHeader += ": ";
      }
      myHeader += myThrowable.getMessage();
    }
    else {
      myHeader = myThrowable.getMessage();
    }
  }
}
 
Example 4
Source File: ErrorReportHandler.java    From leetcode-editor with Apache License 2.0 5 votes vote down vote up
@Override
public boolean submit(@NotNull IdeaLoggingEvent[] events, @Nullable String additionalInfo, @NotNull Component parentComponent, @NotNull Consumer<SubmittedReportInfo> consumer) {
    for (IdeaLoggingEvent event : events) {
        Throwable throwable = event.getThrowable();
        if (event.getData() instanceof AbstractMessage) {
            throwable = ((AbstractMessage) event.getData()).getThrowable();
        }

        SentryUtils.submitErrorReport(throwable, additionalInfo);
    }

    return true;
}
 
Example 5
Source File: SentryBugReporter.java    From protobuf-jetbrains-plugin with Apache License 2.0 5 votes vote down vote up
@NotNull
private EventBuilder createEvent(@NotNull IdeaLoggingEvent[] events, @Nullable String additionalInfo) {
    IdeaLoggingEvent ideaEvent = events[0];
    EventBuilder eventBuilder = new EventBuilder();
    eventBuilder.withMessage(ideaEvent.getMessage());
    eventBuilder.withRelease(getPluginVersion());
    eventBuilder.withTag(TAG_PLATFORM_VERSION, getPlatformVersion());
    eventBuilder.withTag(TAG_OS, SystemInfo.OS_NAME);
    eventBuilder.withTag(TAG_OS_VERSION, SystemInfo.OS_VERSION);
    eventBuilder.withTag(TAG_OS_ARCH, SystemInfo.OS_ARCH);
    eventBuilder.withTag(TAG_JAVA_VERSION, SystemInfo.JAVA_VERSION);
    eventBuilder.withTag(TAG_JAVA_RUNTIME_VERSION, SystemInfo.JAVA_RUNTIME_VERSION);
    Object data = ideaEvent.getData();
    if (data instanceof LogMessage) {
        LogMessage logMessage = (LogMessage) data;
        Throwable throwable = logMessage.getThrowable();
        eventBuilder.withSentryInterface(new ExceptionInterface(throwable));
    } else if (ideaEvent.getThrowable() != null) {
        eventBuilder.withSentryInterface(new ExceptionInterface(ideaEvent.getThrowable()));
    }
    if (additionalInfo != null) {
        eventBuilder.withExtra(EXTRA_ADDITIONAL_INFO, additionalInfo);
    }
    if (events.length > 1) {
        eventBuilder.withExtra(EXTRA_MORE_EVENTS, getMoreEvents(events));
    }
    eventBuilder.withExtra(EXTRA_OTHER_PLUGINS, getOtherPluginsInfo());
    return eventBuilder;
}
 
Example 6
Source File: ITNReporter.java    From consulo with Apache License 2.0 5 votes vote down vote up
/**
 * @noinspection ThrowablePrintStackTrace
 */
private static boolean sendError(IdeaLoggingEvent event,
                                 String additionalInfo,
                                 final Component parentComponent,
                                 final Consumer<SubmittedReportInfo> callback) {
  ErrorReportBean errorBean = new ErrorReportBean(event.getThrowable(), LastActionTracker.ourLastActionId);

  return doSubmit(event, parentComponent, callback, errorBean, additionalInfo);
}