From e46b4c4202b5d9da01d2b45b30a786e301e7d8c8 Mon Sep 17 00:00:00 2001 From: irengrig Date: Mon, 7 Mar 2016 13:32:59 +0100 Subject: [PATCH] WEB-20557 JSON Schema: provide warning about required type Object for the schema to be read --- .../jsonSchema/JsonSchemaMappingsConfigurable.java | 1 + .../jetbrains/jsonSchema/impl/JsonSchemaReader.java | 11 ++++++++++- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/json/src/com/jetbrains/jsonSchema/JsonSchemaMappingsConfigurable.java b/json/src/com/jetbrains/jsonSchema/JsonSchemaMappingsConfigurable.java index 9646a175c71c..4e5989a89d5f 100644 --- a/json/src/com/jetbrains/jsonSchema/JsonSchemaMappingsConfigurable.java +++ b/json/src/com/jetbrains/jsonSchema/JsonSchemaMappingsConfigurable.java @@ -374,6 +374,7 @@ public class JsonSchemaMappingsConfigurable extends MasterDetailsComponent imple myText = FileUtil.loadFile(ioFile); } catch (IOException e1) { + JsonSchemaReader.LOG.info(e1); myError = "Problem during reading JSON schema from '" + myFile.getName() + "': " + e1.getMessage(); return false; } diff --git a/json/src/com/jetbrains/jsonSchema/impl/JsonSchemaReader.java b/json/src/com/jetbrains/jsonSchema/impl/JsonSchemaReader.java index 43d06da54d44..679e6a3afab7 100644 --- a/json/src/com/jetbrains/jsonSchema/impl/JsonSchemaReader.java +++ b/json/src/com/jetbrains/jsonSchema/impl/JsonSchemaReader.java @@ -5,6 +5,7 @@ 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.openapi.diagnostic.Logger; import com.intellij.util.Consumer; import com.intellij.util.ThrowablePairConsumer; import org.jetbrains.annotations.NotNull; @@ -18,6 +19,7 @@ import java.util.*; * @author Irina.Chernushina on 8/27/2015. */ public class JsonSchemaReader { + public static final Logger LOG = Logger.getInstance("#com.jetbrains.jsonSchema.impl.JsonSchemaReader"); public static final NotificationGroup ERRORS_NOTIFICATION = NotificationGroup.logOnlyGroup("JSON Schema"); public JsonSchemaObject read(@NotNull final Reader reader) throws IOException { @@ -43,9 +45,11 @@ public class JsonSchemaReader { new JsonSchemaReader().read(new java.io.StringReader(string)); return true; } catch (IOException e) { + LOG.info(e); errorConsumer.consume(e.getMessage()); return false; } catch (Exception e) { + LOG.info(e); errorConsumer.consume(e.getMessage()); return false; } @@ -293,7 +297,12 @@ public class JsonSchemaReader { } private JsonSchemaType parseType(JsonReader in) throws IOException { - return JsonSchemaType.valueOf("_" + in.nextString()); + final String typeString = in.nextString(); + try { + return JsonSchemaType.valueOf("_" + typeString); + } catch (IllegalArgumentException e) { + throw new IOException("Wrong type value: " + typeString + "\""); + } } }; }