mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
WEB-20369 JSON Schema: copy errors found on reading schema into the Event Log
This commit is contained in:
@@ -2,6 +2,7 @@ package com.jetbrains.jsonSchema;
|
||||
|
||||
import com.intellij.openapi.options.ConfigurationException;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.ui.MessageType;
|
||||
import com.intellij.openapi.ui.NamedConfigurable;
|
||||
import com.intellij.openapi.util.Comparing;
|
||||
import com.intellij.openapi.util.io.FileUtil;
|
||||
@@ -104,14 +105,21 @@ public class JsonSchemaConfigurable extends NamedConfigurable<JsonSchemaMappings
|
||||
final String message;
|
||||
if (collectConsumer.getResult().isEmpty()) message = "Can not read JSON schema from file (Unknown reason)";
|
||||
else message = "Can not read JSON schema from file: " + StringUtil.join(collectConsumer.getResult(), "; ");
|
||||
logErrorForUser(message);
|
||||
throw new ConfigurationException(message);
|
||||
}
|
||||
}
|
||||
catch (IOException e) {
|
||||
throw new ConfigurationException("Can not read JSON schema from file: " + e.getMessage());
|
||||
final String message = "Can not read JSON schema from file: " + e.getMessage();
|
||||
logErrorForUser(message);
|
||||
throw new ConfigurationException(message);
|
||||
}
|
||||
}
|
||||
|
||||
private void logErrorForUser(@NotNull final String error) {
|
||||
JsonSchemaReader.ERRORS_NOTIFICATION.createNotification(error, MessageType.ERROR).notify(myProject);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void reset() {
|
||||
if (myView == null) return;
|
||||
|
||||
@@ -12,6 +12,7 @@ import com.intellij.openapi.project.DumbAwareAction;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.project.ProjectManager;
|
||||
import com.intellij.openapi.ui.MasterDetailsComponent;
|
||||
import com.intellij.openapi.ui.MessageType;
|
||||
import com.intellij.openapi.ui.Messages;
|
||||
import com.intellij.openapi.util.io.FileUtil;
|
||||
import com.intellij.openapi.util.text.StringUtil;
|
||||
@@ -140,6 +141,7 @@ public class JsonSchemaMappingsConfigurable extends MasterDetailsComponent imple
|
||||
final JsonSchemaChecker importer = new JsonSchemaChecker(file, true);
|
||||
if (!importer.checkSchemaFile()) {
|
||||
if (!StringUtil.isEmptyOrSpaces(importer.getError())) {
|
||||
JsonSchemaReader.ERRORS_NOTIFICATION.createNotification(importer.getError(), MessageType.ERROR).notify(myProject);
|
||||
Messages.showErrorDialog(myProject, importer.getError(), READ_JSON_SCHEMA);
|
||||
}
|
||||
return;
|
||||
|
||||
@@ -4,6 +4,7 @@ import com.google.gson.TypeAdapter;
|
||||
import com.google.gson.stream.JsonReader;
|
||||
import com.google.gson.stream.JsonToken;
|
||||
import com.google.gson.stream.JsonWriter;
|
||||
import com.intellij.notification.NotificationGroup;
|
||||
import com.intellij.util.Consumer;
|
||||
import com.intellij.util.ThrowablePairConsumer;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
@@ -17,6 +18,8 @@ import java.util.*;
|
||||
* @author Irina.Chernushina on 8/27/2015.
|
||||
*/
|
||||
public class JsonSchemaReader {
|
||||
public static final NotificationGroup ERRORS_NOTIFICATION = NotificationGroup.logOnlyGroup("JSON Schema");
|
||||
|
||||
public JsonSchemaObject read(@NotNull final Reader reader) throws IOException {
|
||||
final JsonReader in = new JsonReader(reader);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user