Java Code Examples for com.intellij.util.ExceptionUtil#getThrowableText()

The following examples show how to use com.intellij.util.ExceptionUtil#getThrowableText() . 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: GitHubErrorBean.java    From IntelliJDeodorant with MIT License 5 votes vote down vote up
GitHubErrorBean(Throwable throwable, String lastAction) {
    this.stackTrace = throwable != null ? ExceptionUtil.getThrowableText(throwable) : null;
    this.lastAction = lastAction;
    if (throwable != null) {
        setMessage(throwable.getMessage());
        myExceptionHash = Integer.toHexString(stackTrace.hashCode());
    }
}
 
Example 2
Source File: GraphQLSchemaErrorNode.java    From js-graphql-intellij-plugin with MIT License 5 votes vote down vote up
@Override
public void handleDoubleClickOrEnter(SimpleTree tree, InputEvent inputEvent) {
    final SourceLocation location = getLocation();
    if (location != null && location.getSourceName() != null) {
        GraphQLTreeNodeNavigationUtil.openSourceLocation(myProject, location, false);
    } else if (error instanceof GraphQLInternalSchemaError) {
        String stackTrace = ExceptionUtil.getThrowableText(((GraphQLInternalSchemaError) error).getException());
        PsiFile file = PsiFileFactory.getInstance(myProject).createFileFromText("graphql-error.txt", PlainTextLanguage.INSTANCE, stackTrace);
        new OpenFileDescriptor(myProject, file.getVirtualFile()).navigate(true);
    }
}
 
Example 3
Source File: TreeState.java    From consulo with Apache License 2.0 5 votes vote down vote up
@Override
public String toString() {
  Element st = new Element("TreeState");
  String content;
  try {
    writeExternal(st);
    content = JDOMUtil.writeChildren(st, "\n");
  }
  catch (IOException e) {
    content = ExceptionUtil.getThrowableText(e);
  }
  return "TreeState(" + myScrollToSelection + ")\n" + content;
}
 
Example 4
Source File: ErrorReportBean.java    From consulo with Apache License 2.0 5 votes vote down vote up
public ErrorReportBean(Throwable throwable, String lastAction) {
  if (throwable != null) {
    message = throwable.getMessage();
    stackTrace = ExceptionUtil.getThrowableText(throwable);
  }
  this.lastAction = lastAction;
}
 
Example 5
Source File: LogUtil.java    From consulo with Apache License 2.0 5 votes vote down vote up
public static String getProcessList() {
  try {
    @SuppressWarnings("SpellCheckingInspection") Process process = new ProcessBuilder()
            .command(SystemInfo.isWindows ? new String[]{System.getenv("windir") + "\\system32\\tasklist.exe", "/v"} : new String[]{"ps", "a"})
            .redirectErrorStream(true)
            .start();
    return FileUtil.loadTextAndClose(process.getInputStream());
  }
  catch (IOException e) {
    return ExceptionUtil.getThrowableText(e);
  }
}
 
Example 6
Source File: LookupOffsets.java    From consulo with Apache License 2.0 5 votes vote down vote up
@Override
public void documentChanged(@Nonnull DocumentEvent e) {
  if (myStartMarkerDisposeInfo == null && !myLookupStartMarker.isValid()) {
    Throwable throwable = new Throwable();
    String eString = e.toString();
    myStartMarkerDisposeInfo = () -> eString + "\n" + ExceptionUtil.getThrowableText(throwable);
  }
}
 
Example 7
Source File: LookupOffsets.java    From consulo with Apache License 2.0 5 votes vote down vote up
int getLookupStart(@Nullable Throwable disposeTrace) {
  if (!myLookupStartMarker.isValid()) {
    throw new AssertionError("Invalid lookup start: " +
                             myLookupStartMarker +
                             ", " +
                             myEditor +
                             ", disposeTrace=" +
                             (disposeTrace == null ? null : ExceptionUtil.getThrowableText(disposeTrace)) +
                             "\n================\n start dispose trace=" +
                             (myStartMarkerDisposeInfo == null ? null : myStartMarkerDisposeInfo.get()));
  }
  return myLookupStartMarker.getStartOffset();
}
 
Example 8
Source File: UiInspectorAction.java    From consulo with Apache License 2.0 5 votes vote down vote up
private static void processContainerEvent(ContainerEvent event) {
  Component child = event.getID() == ContainerEvent.COMPONENT_ADDED ? event.getChild() : null;
  if (child instanceof JComponent && !(event.getSource() instanceof CellRendererPane)) {
    String text = ExceptionUtil.getThrowableText(new Throwable());
    int first = text.indexOf("at com.intellij", text.indexOf("at java.awt"));
    int last = text.indexOf("at java.awt.EventQueue");
    if (last == -1) last = text.length();
    String val = last > first && first > 0 ?  text.substring(first, last): null;
    ((JComponent)child).putClientProperty("uiInspector.addedAt", val);
  }
}
 
Example 9
Source File: AttachmentImpl.java    From consulo with Apache License 2.0 4 votes vote down vote up
public AttachmentImpl(@Nonnull String name, @Nonnull Throwable throwable) {
  this(name + ".trace", ExceptionUtil.getThrowableText(throwable));
}
 
Example 10
Source File: FocusRequestInfo.java    From consulo with Apache License 2.0 4 votes vote down vote up
public String getStackTrace() {
  return ExceptionUtil.getThrowableText(trace);
}
 
Example 11
Source File: FrequentEventDetector.java    From consulo with Apache License 2.0 4 votes vote down vote up
public void eventHappened(@Nonnull Object event) {
  if (!enabled) return;
  if (myEventsPosted.incrementAndGet() > myEventCountThreshold) {
    boolean shouldLog = false;

    synchronized (myEventsPosted) {
      if (myEventsPosted.get() > myEventCountThreshold) {
        long timeNow = System.currentTimeMillis();
        shouldLog = timeNow - myStartedCounting < myTimeSpanMs;
        myEventsPosted.set(0);
        myStartedCounting = timeNow;
      }
    }

    if (shouldLog) {
      String trace = ExceptionUtil.getThrowableText(new Throwable());
      boolean logTrace;
      int traceId;
      synchronized (myEventsPosted) {
        Integer existingTraceId = myRecentTraces.get(trace);
        logTrace = existingTraceId == null;
        if (logTrace) {
          myRecentTraces.put(trace, traceId = myLastTraceId.incrementAndGet());
        }
        else {
          traceId = existingTraceId;
        }
      }

      String message = "Too many events posted, #" + traceId  + ". Event: "+event +
                       (logTrace ? "\n" + trace : "");
      if (myLevel == Level.INFO) {
        LOG.info(message);
      }
      else if (myLevel == Level.WARN) {
        LOG.warn(message);
      }
      else {
        LOG.error(message);
      }
    }
  }
}
 
Example 12
Source File: BaseComponentAdapter.java    From consulo with Apache License 2.0 4 votes vote down vote up
private static String exceptionText(String id) {
  Thread thread = Thread.currentThread();
  return ExceptionUtil.getThrowableText(new Exception(id + ". Thread: " + thread));
}
 
Example 13
Source File: BoundedTaskExecutor.java    From consulo with Apache License 2.0 4 votes vote down vote up
/**
 * @deprecated use {@link AppExecutorUtil#createBoundedApplicationPoolExecutor(String, Executor, int)} instead
 */
@Deprecated
public BoundedTaskExecutor(@Nonnull Executor backendExecutor, int maxSimultaneousTasks) {
  this(ExceptionUtil.getThrowableText(new Throwable("Creation point:")), backendExecutor, maxSimultaneousTasks, true);
}
 
Example 14
Source File: LookupImpl.java    From consulo with Apache License 2.0 4 votes vote down vote up
public static String getLastLookupDisposeTrace() {
  return ExceptionUtil.getThrowableText(staticDisposeTrace);
}
 
Example 15
Source File: LookupImpl.java    From consulo with Apache License 2.0 4 votes vote down vote up
private String formatDisposeTrace() {
  return ExceptionUtil.getThrowableText(disposeTrace) + "\n============";
}