List of usage examples for com.fasterxml.jackson.core JsonProcessingException getOriginalMessage
public String getOriginalMessage()
From source file:com.aerofs.baseline.json.JsonProcessingExceptionMapper.java
@Override protected String getErrorText(JsonProcessingException throwable) { return throwable.getOriginalMessage(); }
From source file:com.github.fge.jsonschema.load.URIManager.java
/** * Get the content at a given URI as a {@link JsonNode} * * @param uri the URI/*from w w w. ja va 2s . com*/ * @return the content * @throws ProcessingException scheme is not registered, failed to get * content, or content is not JSON */ public JsonNode getContent(final URI uri) throws ProcessingException { Preconditions.checkNotNull(uri, "null URI"); final URI target = schemaRedirects.containsKey(uri) ? schemaRedirects.get(uri) : uri; if (!target.isAbsolute()) throw new ProcessingException(BUNDLE.message("uriNotAbsolute").put("uri", uri)); final String scheme = target.getScheme(); final URIDownloader downloader = downloaders.get(scheme); if (downloader == null) throw new ProcessingException(BUNDLE.message("unhandledScheme").put("uri", uri).put("scheme", scheme)); final InputStream in; try { in = downloader.fetch(target); return READER.readTree(in); } catch (JsonProcessingException e) { throw new ProcessingException( BUNDLE.message("uriNotJson").put("uri", uri).put("parsingMessage", e.getOriginalMessage())); } catch (IOException e) { throw new ProcessingException( BUNDLE.message("uriIOError").put("uri", uri).put("exceptionMessage", e.getMessage())); } }
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(); /*/*from www . ja v a 2 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:org.apereo.openlrs.controllers.xapi.XAPIExceptionHandlerAdvice.java
@ExceptionHandler(HttpMessageNotReadableException.class) @ResponseStatus(value = HttpStatus.BAD_REQUEST) @ResponseBody//w ww . ja v a 2 s .co m public XAPIErrorInfo handleHttpMessageNotReadableException(final HttpServletRequest request, HttpMessageNotReadableException e) { if (e.getCause() instanceof UnrecognizedPropertyException) { return this.handleUnrecognizedPropertyException(request, (UnrecognizedPropertyException) e.getCause()); } else { XAPIErrorInfo result; if (e.getCause() instanceof JsonProcessingException) { final JsonProcessingException jpe = (JsonProcessingException) e.getCause(); result = new XAPIErrorInfo(HttpStatus.BAD_REQUEST, request, jpe.getOriginalMessage()); } else { result = new XAPIErrorInfo(HttpStatus.BAD_REQUEST, request, e); } this.logException(e); this.logError(result); return result; } }
From source file:com.unboundid.scim2.server.providers.JsonProcessingExceptionMapper.java
/** * {@inheritDoc}/* ww w . ja v a 2 s .c o m*/ */ 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(); }