public MeasurementException(String message, Object... params) { super(format(message, params)); }
response = service.query(request); } catch (ExpressionException e) { throw getException(Status.BAD_REQUEST, e, "An error occurred while evaluating an expression: {}", e.getMessage()); } catch (FilterException | ValidationException e) { throw getException(Status.BAD_REQUEST, e, e.getMessage()); } catch (ResourceNotFoundException e) { throw getException(Status.NOT_FOUND, e, e.getMessage()); } catch (FetchException e) { throw getException(Status.INTERNAL_SERVER_ERROR, e, e.getMessage()); } catch (Exception e) { throw getException(Status.INTERNAL_SERVER_ERROR, e, "Query failed: {}", e.getMessage());
/** * Successively applies all of the filters. */ public void filter(final List<FilterDef> filterDefinitions, final RowSortedTable<Long, String, Double> table) throws FilterException { Preconditions.checkNotNull(filterDefinitions, "filterDefinitions argument"); Preconditions.checkNotNull(table, "table argument"); for (FilterDef filterDef : filterDefinitions) { Filter filter = getFilter(filterDef); if (filter == null) { throw new FilterException("No filter implementation found for {}", filterDef.getName()); } try { filter.filter(table); } catch (Throwable t) { throw new FilterException(t, "An error occurred while applying filter {}", t.getMessage()); } } }
request.isRelaxed()); } catch (Exception e) { throw new FetchException(e, "Fetch failed: {}", e.getMessage()); throw new ResourceNotFoundException(request);
public void validate(QueryRequest request) throws ValidationException { if (request.getEnd() < 0) { throw new ValidationException("Query end must be >= 0: {}", request.getEnd()); throw new ValidationException("Query step must be > 0: {}", request.getStep()); throw new ValidationException("If either the heartbeat or the interval are set, then both must be set."); throw new ValidationException("Heartbeat must be positive: {}", request.getHeartbeat()); throw new ValidationException("Interval must be positive: {}", request.getInterval()); throw new ValidationException("Step must be a multiple of the interval. Step: {}, Interval: {}", request.getStep(), request.getInterval()); throw new ValidationException("Heartbeat must be a multiple of the interval. Interval: {} Heartbeat: {}", request.getInterval(), request.getHeartbeat()); || source.getLabel() == null || source.getAggregation() == null) { throw new ValidationException("Query source fields must be set: {}", source); throw new ValidationException("Query source label '{}' conflict: source with that label is already defined.", source.getLabel()); } else { labels.put(source.getLabel(), "source"); if (expression.getExpression() == null || expression.getLabel() == null) { throw new ValidationException("Query expression fields must be set: {}", expression);
expressions.put(e.getLabel(), jexl.createExpression(e.getExpression())); } catch (JexlException ex) { throw new ExpressionException(ex, "Failed to parse expression label '{}'.", e.getLabel()); throw new ExpressionException(e, "The return value from expression with label '" + expressionEntry.getKey() + "' could not be cast to a Double."); } catch (JexlException e) { throw new ExpressionException(e, "Failed to evaluate expression with label '" + expressionEntry.getKey() + "'.");
request.isRelaxed()); } catch (Exception e) { throw new FetchException(e, "Fetch failed: {}", e.getMessage()); throw new ResourceNotFoundException(request);
public MeasurementException(Throwable cause, String message, Object... params) { super(format(message, params), cause); }
/** * Successively applies all of the filters. */ public void filter(final List<FilterDef> filterDefinitions, final RowSortedTable<Long, String, Double> table) throws FilterException { Preconditions.checkNotNull(filterDefinitions, "filterDefinitions argument"); Preconditions.checkNotNull(table, "table argument"); for (FilterDef filterDef : filterDefinitions) { Filter filter = getFilter(filterDef); if (filter == null) { throw new FilterException("No filter implementation found for {}", filterDef.getName()); } try { filter.filter(table); } catch (Throwable t) { throw new FilterException(t, "An error occurred while applying filter {}", t.getMessage()); } } }
public void validate(QueryRequest request) throws ValidationException { if (request.getEnd() < 0) { throw new ValidationException("Query end must be >= 0: {}", request.getEnd()); throw new ValidationException("Query step must be > 0: {}", request.getStep()); throw new ValidationException("If either the heartbeat or the interval are set, then both must be set."); throw new ValidationException("Heartbeat must be positive: {}", request.getHeartbeat()); throw new ValidationException("Interval must be positive: {}", request.getInterval()); throw new ValidationException("Step must be a multiple of the interval. Step: {}, Interval: {}", request.getStep(), request.getInterval()); throw new ValidationException("Heartbeat must be a multiple of the interval. Interval: {} Heartbeat: {}", request.getInterval(), request.getHeartbeat()); || source.getLabel() == null || source.getAggregation() == null) { throw new ValidationException("Query source fields must be set: {}", source); throw new ValidationException("Query source label '{}' conflict: source with that label is already defined.", source.getLabel()); } else { labels.put(source.getLabel(), "source"); if (expression.getExpression() == null || expression.getLabel() == null) { throw new ValidationException("Query expression fields must be set: {}", expression);
expressions.put(e.getLabel(), jexl.createExpression(e.getExpression())); } catch (JexlException ex) { throw new ExpressionException(ex, "Failed to parse expression label '{}'.", e.getLabel()); throw new ExpressionException(e, "The return value from expression with label '" + expressionEntry.getKey() + "' could not be cast to a Double."); } catch (JexlException e) { throw new ExpressionException(e, "Failed to evaluate expression with label '" + expressionEntry.getKey() + "'.");
public MeasurementException(Throwable cause, String message, Object... params) { super(format(message, params), cause); }
public MeasurementException(String message, Object... params) { super(format(message, params)); }