Builder setLocation(JsonLocation location) { return location == null ? this : setLocation(location.getLineNr(), location.getColumnNr()); }
private String getLocationString() { JsonLocation l = parser.getCurrentLocation(); List<String> parts = new ArrayList<>(4); parts.add("line: " + l.getLineNr()); parts.add("column: " + l.getColumnNr()); if (l.getByteOffset() >= 0) { parts.add("byte offset: " + l.getByteOffset()); } return parts.toString(); }
String message = format("Unknown property at line %s:%s: %s", ex.getLocation().getLineNr(), ex.getLocation().getColumnNr(), ex.getPropertyName()); throw new IllegalArgumentException(message, e);
@SuppressWarnings("unchecked") public <T> T getWith(LogicalPlanPersistence lpPersistance, Class<T> c) { try { if (opaque != null) { final Class<?> opaqueClass = opaque.getClass(); if (opaqueClass.equals(c)) { return (T) opaque; } else { // Enum values that override methods are given $1, $2 ... extensions. Ignore the extension. // e.g. SystemTable$1 for SystemTable.OPTION if (c.isEnum()) { final String opaqueName = opaqueClass.getName().replaceAll("\\$\\d+$", ""); final String cName = c.getName(); if(opaqueName.equals(cName)) { return (T) opaque; } } throw new IllegalArgumentException(String.format("Attempted to retrieve a option with type of %s. " + "However, the JSON options carried an opaque value of type %s.", c.getName(), opaqueClass.getName())); } } //logger.debug("Read tree {}", root); return lpPersistance.getMapper().treeToValue(root, c); } catch (JsonProcessingException e) { throw new LogicalPlanParsingException(String.format("Failure while trying to convert late bound " + "json options to type of %s. Reference was originally located at line %d, column %d.", c.getCanonicalName(), location.getLineNr(), location.getColumnNr()), e); } }
private Object parseInternal(JsonParser parser) throws SerDeException { try { parser.nextToken(); Object res = parseDispatcher(parser, oi); return res; } catch (Exception e) { String locationStr = parser.getCurrentLocation().getLineNr() + "," + parser.getCurrentLocation().getColumnNr(); throw new SerDeException("at[" + locationStr + "]: " + e.getMessage(), e); } }
String message = format("Unknown property at line %s:%s: %s", ex.getLocation().getLineNr(), ex.getLocation().getColumnNr(), ex.getPropertyName()); throw new IllegalArgumentException(message, e);
public int getColumn() { return _location.getColumnNr(); } public int getLine()
public static void toStringLocation(StringBuilder buf, JsonLocation location) { Object sourceRef = location.getSourceRef(); if (sourceRef instanceof File) { File f = (File) sourceRef; buf.append(f.getPath()); buf.append(": "); } buf.append(location.getLineNr()); buf.append("."); buf.append(location.getColumnNr()); }
protected void reportFatalError(String msg, JsonLocation location) throws RDFParseException { reportFatalError(msg, location.getLineNr(), location.getColumnNr()); }
private String getLocationString() { JsonLocation l = parser.getCurrentLocation(); List<String> parts = new ArrayList<>(4); parts.add("line: " + l.getLineNr()); parts.add("column: " + l.getColumnNr()); if (l.getByteOffset() >= 0) { parts.add("byte offset: " + l.getByteOffset()); } return parts.toString(); }
Builder setLocation(JsonLocation location) { return location == null ? this : setLocation(location.getLineNr(), location.getColumnNr()); }
protected void reportError(String msg, Throwable e, JsonLocation location, RioSetting<Boolean> setting) throws RDFParseException { reportError(msg, location.getLineNr(), location.getColumnNr(), setting); }
protected void reportFatalError(String msg, Throwable e, JsonLocation location) throws RDFParseException { reportFatalError(msg, location.getLineNr(), location.getColumnNr()); }
protected void reportError(String msg, Throwable e, JsonLocation location, RioSetting<Boolean> setting) throws RDFParseException { reportError(msg, location.getLineNr(), location.getColumnNr(), setting); }
@Override public int getColumnNumber() { return jsonParser.getCurrentLocation() != null ? jsonParser.getCurrentLocation().getColumnNr() : -1; } }
protected void reportError(String msg, JsonLocation location, RioSetting<Boolean> setting) throws RDFParseException { reportError(msg, location.getLineNr(), location.getColumnNr(), setting); }
public JSONException(Exception e, JsonLocation location) { super(e); this.location = location.toString(); this.line = location.getLineNr(); this.column = location.getColumnNr(); }
private static StyleConfiguration readConfig(ObjectReader reader, StyleResource config) { try (InputStream is = config.openStream()) { return reader.readValue(is); } catch (JsonProcessingException e) { String message = String.format("Unable to read style configuration %s.\nLocation: line %s, column %s\nDetails: %s", config, e.getLocation().getLineNr(), e.getLocation().getColumnNr(), e.getOriginalMessage()); throw new RuntimeException(message); } catch (IOException e) { throw new RuntimeException(e); } }
@Override public XContentLocation getTokenLocation() { JsonLocation loc = parser.getTokenLocation(); if (loc == null) { return null; } return new XContentLocation(loc.getLineNr(), loc.getColumnNr()); }
@Override public UserException.Builder getExceptionWithContext(UserException.Builder builder, String message) { builder.message(message); JsonLocation location = parser.getCurrentLocation(); builder.addContext("Line", location.getLineNr()) .addContext("Column", location.getColumnNr() + 1); String fieldName = getCurrentField(); if (fieldName != null) { builder.addContext("Field", fieldName); } return builder; }