src/main/java/com/w3asel/cubesensors/api/v1/CubeSensorsApiV1.java
private <T> T parseQuery(final String response, final Class<T> responseClass) {
		T queryResponse;
		try {
			/*
			 * Possible exceptions:
			 *
			 * IOException - if the underlying input source has problems during parsing
			 *
			 * JsonParseException - if parser has problems parsing content
			 *
			 * JsonMappingException - if the parser does not have any more content to map (note: Json "null" value is considered content; enf-of-stream not)
			 */
			queryResponse = MAPPER.readValue(response, responseClass);
		} catch (JsonParseException | JsonMappingException e) {
			try {
				final ErrorResponse error = MAPPER.readValue(response, ErrorResponse.class);

				LOGGER.error("Query returned an error: {}", error);
				return null;
			} catch (final IOException e1) {
				LOGGER.error("Failed to read error response.", e1);
			}
			LOGGER.error("Error reading response.", e);
			return null;
		} catch (final IOException e) {
			LOGGER.error("Error reading response.", e);
			return null;
		}

		return queryResponse;
	}
private <T> T parseQuery(final String response, final Class<T> responseClass) {
		T queryResponse;
		try {
			/*
			 * Possible exceptions:
			 *
			 * IOException - if the underlying input source has problems during parsing
			 *
			 * JsonParseException - if parser has problems parsing content
			 *
			 * JsonMappingException - if the parser does not have any more content to map (note: Json "null" value is considered content; enf-of-stream not)
			 */
			queryResponse = MAPPER.readValue(response, responseClass);
		} catch (JsonParseException | JsonMappingException e) {
			try {
				final ErrorResponse error = MAPPER.readValue(response, ErrorResponse.class);

				LOGGER.error("Query returned an error: {}", error);
				return null;
			} catch (final IOException e1) {
				LOGGER.error("Failed to read error response.", e1);
			}
			LOGGER.error("Error reading response.", e);
			return null;
		} catch (final IOException e) {
			LOGGER.error("Error reading response.", e);
			return null;
		}

		return queryResponse;
	}
Parses the results of a query and handles any errors.