WEB-20557 JSON Schema: provide warning about required type Object for the schema to be read

This commit is contained in:
irengrig
2016-03-07 13:34:02 +01:00
parent 2e0e859f9a
commit e46b4c4202
2 changed files with 11 additions and 1 deletions
@@ -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;
}
@@ -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 + "\"");
}
}
};
}