Java Code Examples for consulo.logging.Logger#error()

The following examples show how to use consulo.logging.Logger#error() . 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: StartupActionScriptManager.java    From consulo with Apache License 2.0 6 votes vote down vote up
@Override
public void execute(final Logger logger) throws IOException {
  if (!mySource.exists()) {
    logger.error("Source file " + mySource.getAbsolutePath() + " does not exist for action " + this);
  }
  else if (!canCreateFile(myDestination)) {
    JOptionPane.showMessageDialog(JOptionPane.getRootFrame(), MessageFormat
                                          .format("<html>Cannot unzip {0}<br>to<br>{1}<br>Please, check your access rights on folder <br>{2}", mySource.getAbsolutePath(), myDestination.getAbsolutePath(), myDestination),
                                  "Installing Plugin", JOptionPane.ERROR_MESSAGE);
  }
  else {
    try {
      ZipUtil.extract(mySource, myDestination, myFilenameFilter);
    }
    catch (Exception ex) {
      logger.error(ex);

      JOptionPane.showMessageDialog(JOptionPane.getRootFrame(), MessageFormat
              .format("<html>Failed to extract ZIP file {0}<br>to<br>{1}<br>You may need to re-download the plugin you tried to install.", mySource.getAbsolutePath(),
                      myDestination.getAbsolutePath()), "Installing Plugin", JOptionPane.ERROR_MESSAGE);
    }
  }
}
 
Example 2
Source File: StartupActionScriptManager.java    From consulo with Apache License 2.0 6 votes vote down vote up
@Override
public void execute(Logger logger) throws IOException {
  if (mySource == null) {
    return;
  }

  if (!mySource.exists()) {
    logger.error("Source file " + mySource.getAbsolutePath() + " does not exist for action " + this);
  }
  else if (!FileUtilRt.delete(mySource)) {
    logger.error("Action " + this + " failed.");

    JOptionPane.showMessageDialog(JOptionPane.getRootFrame(),
                                  MessageFormat.format("<html>Cannot delete {0}<br>Please, check your access rights on folder <br>{1}", mySource.getAbsolutePath(), mySource.getAbsolutePath()),
                                  "Installing Plugin", JOptionPane.ERROR_MESSAGE);
  }
}
 
Example 3
Source File: Promises.java    From consulo with Apache License 2.0 6 votes vote down vote up
public static boolean errorIfNotMessage(Logger logger, Throwable e) {
  if (e instanceof InternalPromiseUtil.MessageError) {
    boolean log = ((InternalPromiseUtil.MessageError)e).log;

    // TODO handle unit test?
    //if (log == ThreeState.YES || (log == ThreeState.UNSURE && ApplicationManager.getApplication().isUnitTestMode())) {
    //  logger.error(e);
    //  return true;
    //}
  }
  else if (!(e instanceof ControlFlowException) && !(e instanceof CancellationException)) {
    logger.error(e);
    return true;
  }

  return false;
}
 
Example 4
Source File: GeneralTestEventsProcessor.java    From consulo with Apache License 2.0 5 votes vote down vote up
public static void logProblem(final Logger log, final String msg, boolean throwError, final String testFrameworkName) {
  final String text = getTFrameworkPrefix(testFrameworkName) + msg;
  if (throwError) {
    log.error(text);
  }
  else {
    log.warn(text);
  }
}
 
Example 5
Source File: PluginExceptionUtil.java    From consulo with Apache License 2.0 5 votes vote down vote up
public static void logPluginError(Logger log, String message, Throwable t, Class<?> aClass) {
  PluginDescriptor plugin = PluginManager.getPlugin(aClass);

  if(plugin == null) {
    log.error(message, t);
  }
  else {
    log.error(new PluginException(message, t, plugin.getPluginId()));
  }
}
 
Example 6
Source File: RunResult.java    From consulo with Apache License 2.0 5 votes vote down vote up
public RunResult logException(Logger logger) {
  if (hasException()) {
    logger.error(myThrowable);
  }

  return this;
}
 
Example 7
Source File: LogMessageEx.java    From consulo with Apache License 2.0 5 votes vote down vote up
public static void error(@Nonnull Logger logger,
                         @Nonnull String message,
                         @Nonnull Throwable cause,
                         @Nonnull String... attachmentText) {
  StringBuilder detailsBuffer = new StringBuilder();
  for (String detail : attachmentText) {
    detailsBuffer.append(detail).append(",");
  }
  if (attachmentText.length > 0 && detailsBuffer.length() > 0) {
    detailsBuffer.setLength(detailsBuffer.length() - 1);
  }
  Attachment attachment = detailsBuffer.length() > 0 ? AttachmentFactory.get().create("current-context.txt", detailsBuffer.toString()) : null;
  logger.error(createEvent(message, ExceptionUtil.getThrowableText(cause), null, null, attachment));
}
 
Example 8
Source File: ExceptionUtil.java    From consulo with Apache License 2.0 5 votes vote down vote up
@Nonnull
public static String getUserStackTrace(@Nonnull Throwable aThrowable, Logger logger) {
  final String result = getThrowableText(aThrowable, "com.intellij.");
  if (!result.contains("\n\tat")) {
    // no stack frames found
    logger.error(aThrowable);
  }
  return result;
}
 
Example 9
Source File: StartupActionScriptManager.java    From consulo with Apache License 2.0 4 votes vote down vote up
private static List<ActionCommand> loadStartActions(Logger logger) throws IOException {
  List<ActionCommand> actionCommands = loadObsoleteActionScriptFile(logger);
  if (!actionCommands.isEmpty()) {
    return actionCommands;
  }

  File file = new File(getStartXmlFilePath());

  if (file.exists()) {
    try {
      SAXBuilder builder = new SAXBuilder(XMLReaders.NONVALIDATING);

      Document document = builder.build(file);

      Element rootElement = document.getRootElement();
      List<ActionCommand> list = new ArrayList<ActionCommand>();

      for (Element element : rootElement.getChildren()) {
        String name = element.getName();
        if (DeleteCommand.action.equals(name)) {
          String path = element.getAttributeValue("source");
          list.add(new DeleteCommand(new File(path)));
        }
        else if (UnzipCommand.action.equals(name)) {
          String sourceValue = element.getAttributeValue("source");
          String descriptionValue = element.getAttributeValue("description");
          String filter = element.getAttributeValue("filter");
          FilenameFilter filenameFilter = null;
          if ("import".equals(filter)) {
            Set<String> names = new HashSet<String>();
            for (Element child : element.getChildren()) {
              names.add(child.getTextTrim());
            }
            filenameFilter = new ImportSettingsFilenameFilter(names);
          }

          list.add(new UnzipCommand(new File(sourceValue), new File(descriptionValue), filenameFilter));
        }
      }

      return list;
    }
    catch (Exception e) {
      logger.error(e);
      return Collections.emptyList();
    }
  }
  else {
    logger.warn("No " + ourStartXmlFileName + " file");
    return Collections.emptyList();
  }
}