public FailureInfo toFailureInfo() { List<FailureInfo> suppressed = this.suppressed.stream() .map(ExecutionFailureInfo::toFailureInfo) .collect(toImmutableList()); return new FailureInfo(type, message, cause == null ? null : cause.toFailureInfo(), suppressed, stack, errorLocation); }
@Nullable @JsonProperty public FailureInfo getLastFailureInfo() { Exception lastFailureException = getLastFailureException(); if (lastFailureException == null) { return null; } return Failures.toFailure(lastFailureException).toFailureInfo(); }
private static Expression createFailureFunction(RuntimeException exception, Type type) { requireNonNull(exception, "Exception is null"); String failureInfo = JsonCodec.jsonCodec(FailureInfo.class).toJson(Failures.toFailure(exception).toFailureInfo()); FunctionCall jsonParse = new FunctionCall(QualifiedName.of("json_parse"), ImmutableList.of(new StringLiteral(failureInfo))); FunctionCall failureFunction = new FunctionCall(QualifiedName.of("fail"), ImmutableList.of(jsonParse)); return new Cast(failureFunction, type.getTypeSignature().toString()); }
failure = queryInfo.getFailureInfo().toFailureInfo(); failure = toFailure(new RuntimeException(format("Query is %s (reason unknown)", state))).toFailureInfo();
FailureInfo failure = queryInfo.getFailureInfo().toFailureInfo(); assertNotNull(failure); assertEquals(failure.getType(), expectedException.getClass().getName());
public FailureInfo toFailureInfo() { List<FailureInfo> suppressed = this.suppressed.stream() .map(ExecutionFailureInfo::toFailureInfo) .collect(toImmutableList()); return new FailureInfo(type, message, cause == null ? null : cause.toFailureInfo(), suppressed, stack, errorLocation); }
@VisibleForTesting public static Expression createFailureFunction(RuntimeException exception, Type type) { requireNonNull(exception, "Exception is null"); String failureInfo = JsonCodec.jsonCodec(FailureInfo.class).toJson(Failures.toFailure(exception).toFailureInfo()); FunctionCall jsonParse = new FunctionCall(QualifiedName.of("json_parse"), ImmutableList.of(new StringLiteral(failureInfo))); FunctionCall failureFunction = new FunctionCall(QualifiedName.of("fail"), ImmutableList.of(jsonParse)); return new Cast(failureFunction, type.getTypeSignature().toString()); }
private static QueryError toQueryError(QueryInfo queryInfo) { FailureInfo failure = queryInfo.getFailureInfo(); if (failure == null) { QueryState state = queryInfo.getState(); if ((!state.isDone()) || (state == QueryState.FINISHED)) { return null; } log.warn("Query %s in state %s has no failure info", queryInfo.getQueryId(), state); failure = toFailure(new RuntimeException(format("Query is %s (reason unknown)", state))).toFailureInfo(); } ErrorCode errorCode; if (queryInfo.getErrorCode() != null) { errorCode = queryInfo.getErrorCode(); } else { errorCode = INTERNAL_ERROR.toErrorCode(); log.warn("Failed query %s has no error code", queryInfo.getQueryId()); } return new QueryError( failure.getMessage(), null, errorCode.getCode(), errorCode.getName(), toErrorType(errorCode.getCode()).toString(), failure.getErrorLocation(), failure); }
ExecutionFailureInfo failureCause = this.failureCause.get(); if (failureCause != null) { failureInfo = failureCause.toFailureInfo(); errorCode = failureCause.getErrorCode();