List of usage examples for com.fasterxml.jackson.core JsonProcessingException getLocation
public JsonLocation getLocation()
From source file:com.github.fge.jsonschema.servlets.SyntaxValidateServlet.java
private static JsonNode buildParsingError(final JsonProcessingException e, final boolean crlf) { final JsonLocation location = e.getLocation(); final ObjectNode ret = JsonNodeFactory.instance.objectNode(); /*// www. ja v a2 s .c o m * Unfortunately, for some reason, Jackson botches the column number in * its JsonPosition -- I cannot figure out why exactly. However, it does * have a correct offset into the buffer. * * The problem is that if the input has CR/LF line terminators, its * offset will be "off" by the number of lines minus 1 with regards to * what JavaScript sees as positions in text areas. Make the necessary * adjustments so that the caret jumps at the correct position in this * case. */ final int lineNr = location.getLineNr(); int offset = (int) location.getCharOffset(); if (crlf) offset = offset - lineNr + 1; ret.put(ParseError.LINE, lineNr); ret.put(ParseError.OFFSET, offset); // Finally, put the message ret.put(ParseError.MESSAGE, e.getOriginalMessage()); return ret; }
From source file:io.fabric8.maven.core.util.KubernetesResourceUtil.java
private static Map<String, Object> readFragment(File file, String ext) throws IOException { ObjectMapper mapper = new ObjectMapper("json".equals(ext) ? new JsonFactory() : new YAMLFactory()); TypeReference<HashMap<String, Object>> typeRef = new TypeReference<HashMap<String, Object>>() { };//from w w w. j ava2 s . co m try { Map<String, Object> ret = mapper.readValue(file, typeRef); return ret != null ? ret : new HashMap<String, Object>(); } catch (JsonProcessingException e) { throw new JsonMappingException(String.format("[%s] %s", file, e.getMessage()), e.getLocation(), e); } }
From source file:org.bonitasoft.web.designer.controller.asset.MalformedJsonException.java
public MalformedJsonException(JsonProcessingException cause) { super(cause); this.location = cause.getLocation(); }
From source file:com.reprezen.swagedit.validation.SwaggerError.java
public SwaggerError(JsonProcessingException exception) { this.level = IMarker.SEVERITY_ERROR; this.message = exception.getMessage(); if (exception.getLocation() != null) { this.line = exception.getLocation().getLineNr(); } else {/* w ww . j a va2 s . co m*/ this.line = 1; } }
From source file:com.unboundid.scim2.server.providers.JsonProcessingExceptionMapper.java
/** * {@inheritDoc}//from w ww . j a va 2 s .c om */ public Response toResponse(final JsonProcessingException exception) { ErrorResponse errorResponse; if ((exception instanceof JsonParseException) || (exception instanceof JsonMappingException)) { StringBuilder builder = new StringBuilder(); builder.append("Unable to parse request: "); builder.append(exception.getOriginalMessage()); if (exception.getLocation() != null) { builder.append(" at line: "); builder.append(exception.getLocation().getLineNr()); builder.append(", column: "); builder.append(exception.getLocation().getColumnNr()); } errorResponse = BadRequestException.invalidSyntax(builder.toString()).getScimError(); } else { if (exception.getCause() != null && exception.getCause() instanceof ScimException) { errorResponse = ((ScimException) exception.getCause()).getScimError(); } else { errorResponse = new ServerErrorException(exception.getMessage()).getScimError(); } } return ServerUtils.setAcceptableType(Response.status(errorResponse.getStatus()).entity(errorResponse), headers.getAcceptableMediaTypes()).build(); }