logger.debug("mutation response={}", mutationResponse); } catch (AtlasServiceException e) { if (e.getStatus().getStatusCode() == AtlasErrorCode.INSTANCE_NOT_FOUND.getHttpCode().getStatusCode() && e.getMessage().contains(AtlasErrorCode.INSTANCE_NOT_FOUND.getErrorCode())) {
boolean logException(Throwable t) { if (t instanceof AtlasBaseException) { Response.Status httpCode = ((AtlasBaseException) t).getAtlasErrorCode().getHttpCode(); return httpCode != Response.Status.NOT_FOUND && httpCode != Response.Status.NO_CONTENT; } else if (t instanceof NotFoundException) { return false; } else { return true; } }
boolean logException(Throwable t) { if (t instanceof AtlasBaseException) { Response.Status httpCode = ((AtlasBaseException) t).getAtlasErrorCode().getHttpCode(); return httpCode != Response.Status.NOT_FOUND && httpCode != Response.Status.NO_CONTENT; } else if (t instanceof NotFoundException) { return false; } else { return true; } }
@Override public Response toResponse(AtlasBaseException exception) { final long id = ThreadLocalRandom.current().nextLong(); // Only log the exception is there's an internal error if (exception.getAtlasErrorCode().getHttpCode() == Response.Status.INTERNAL_SERVER_ERROR) { ExceptionMapperUtil.logException(id, exception); } return buildAtlasBaseExceptionResponse(exception); }
protected Response buildAtlasBaseExceptionResponse(AtlasBaseException baseException) { Map<String, String> errorJsonMap = new LinkedHashMap<>(); AtlasErrorCode errorCode = baseException.getAtlasErrorCode(); errorJsonMap.put("errorCode", errorCode.getErrorCode()); errorJsonMap.put("errorMessage", baseException.getMessage()); if (baseException.getCause() != null) { errorJsonMap.put("errorCause", baseException.getCause().getMessage()); } Response.ResponseBuilder responseBuilder = Response.status(errorCode.getHttpCode()); // No body for 204 (and maybe 304) if (Response.Status.NO_CONTENT != errorCode.getHttpCode()) { responseBuilder.entity(AtlasType.toJson(errorJsonMap)); } return responseBuilder.build(); } }
public static Response getErrorResponse(AtlasBaseException e) { String message = e.getMessage() == null ? "Failed with " + e.getClass().getName() : e.getMessage(); Response response = getErrorResponse(message, e.getAtlasErrorCode().getHttpCode()); return response; }
} catch (AtlasBaseException e) { LOG.error("Unable to get schema for entity={}", guid, e); throw new WebApplicationException(Servlets.getErrorResponse(e, e.getAtlasErrorCode().getHttpCode())); } catch (Throwable e) { LOG.error("Unable to get schema for entity={}", guid, e);
public static WebApplicationException toWebApplicationException(AtlasBaseException e) { if (e.getAtlasErrorCode() == AtlasErrorCode.CLASSIFICATION_NOT_FOUND || e.getAtlasErrorCode() == AtlasErrorCode.INSTANCE_GUID_NOT_FOUND || e.getAtlasErrorCode() == AtlasErrorCode.INSTANCE_BY_UNIQUE_ATTRIBUTE_NOT_FOUND) { return new WebApplicationException(Servlets.getErrorResponse(e, Response.Status.NOT_FOUND)); } if (e.getAtlasErrorCode() == AtlasErrorCode.INVALID_PARAMETERS || e.getAtlasErrorCode() == AtlasErrorCode.INSTANCE_CRUD_INVALID_PARAMS) { return new WebApplicationException(Servlets.getErrorResponse(e, Response.Status.BAD_REQUEST)); } return new WebApplicationException(Servlets.getErrorResponse(e, e.getAtlasErrorCode().getHttpCode())); }
logger.debug("mutation response={}", mutationResponse); } catch (AtlasServiceException e) { if (e.getStatus().getStatusCode() == AtlasErrorCode.INSTANCE_NOT_FOUND.getHttpCode().getStatusCode() && e.getMessage().contains(AtlasErrorCode.INSTANCE_NOT_FOUND.getErrorCode())) {