private static FailureException toException(FailureInfo failureInfo) { if (failureInfo == null) { return null; } FailureException failure = new FailureException(failureInfo.getType(), failureInfo.getMessage(), toException(failureInfo.getCause())); for (FailureInfo suppressed : failureInfo.getSuppressed()) { failure.addSuppressed(toException(suppressed)); } ImmutableList.Builder<StackTraceElement> stackTraceBuilder = ImmutableList.builder(); for (String stack : failureInfo.getStack()) { stackTraceBuilder.add(toStackTraceElement(stack)); } ImmutableList<StackTraceElement> stackTrace = stackTraceBuilder.build(); failure.setStackTrace(stackTrace.toArray(new StackTraceElement[stackTrace.size()])); return failure; }
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); }
public RuntimeException toException() { return toException(this); }
com.facebook.presto.client.ErrorLocation errorLocation = error.getErrorLocation(); QueryError queryError = new QueryError( Optional.ofNullable(error.getFailureInfo().getMessage()) .orElse(error.getFailureInfo().toException().toString()), error.getSqlState(), error.getErrorCode(),
FailureInfo failureInfo = queryInfo.getFailureInfo(); String failureType = failureInfo == null ? null : failureInfo.getType(); String failureMessage = failureInfo == null ? null : failureInfo.getMessage();
firstNonNull(failure.getMessage(), "Internal error"), null, errorCode.getCode(), errorCode.getName(), errorCode.getType().toString(), failure.getErrorLocation(), failure);
FailureInfo failure = queryInfo.getFailureInfo().toFailureInfo(); assertNotNull(failure); assertEquals(failure.getType(), expectedException.getClass().getName()); if (expectedException instanceof PrestoException) { assertEquals(queryInfo.getErrorCode(), ((PrestoException) expectedException).getErrorCode());
private static RuntimeException getCause(QueryError queryError) { if (queryError.getFailureInfo() != null) { return queryError.getFailureInfo().toException(); } return null; }
FailureInfo failure = queryInfo.getFailureInfo(); assertNotNull(failure); assertEquals(failure.getMessage(), FAILED_CAUSE.getMessage()); assertEquals(failure.getType(), FAILED_CAUSE.getClass().getName());
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); }
private static FailureException toException(FailureInfo failureInfo) { if (failureInfo == null) { return null; } FailureException failure = new FailureException(failureInfo.getType(), failureInfo.getMessage(), toException(failureInfo.getCause())); for (FailureInfo suppressed : failureInfo.getSuppressed()) { failure.addSuppressed(toException(suppressed)); } ImmutableList.Builder<StackTraceElement> stackTraceBuilder = ImmutableList.builder(); for (String stack : failureInfo.getStack()) { stackTraceBuilder.add(toStackTraceElement(stack)); } ImmutableList<StackTraceElement> stackTrace = stackTraceBuilder.build(); failure.setStackTrace(stackTrace.toArray(new StackTraceElement[stackTrace.size()])); return failure; }
public void renderFailure(PrintStream out) { QueryStatusInfo results = client.finalStatusInfo(); QueryError error = results.getError(); checkState(error != null); out.printf("Query %s failed: %s%n", results.getId(), error.getMessage()); if (debug && (error.getFailureInfo() != null)) { error.getFailureInfo().toException().printStackTrace(out); } if (error.getErrorLocation() != null) { renderErrorLocation(client.getQuery(), error.getErrorLocation(), out); } out.println(); }
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); }
@Description("Decodes json to an exception and throws it") @ScalarFunction(value = "fail", hidden = true) @SqlType("unknown") public static boolean failWithException(@SqlType(StandardTypes.JSON) Slice failureInfoSlice) { FailureInfo failureInfo = JSON_CODEC.fromJson(failureInfoSlice.getBytes()); // wrap the failure in a new exception to append the current stack trace throw new PrestoException(StandardErrorCode.GENERIC_USER_ERROR, failureInfo.toException()); }
RuntimeException remoteException = error.getFailureInfo().toException(); throw new RuntimeException(Optional.ofNullable(remoteException.getMessage()).orElseGet(remoteException::toString), remoteException);
public RuntimeException toException() { return toException(this); }
public void renderFailure(PrintStream out) { QueryStatusInfo results = client.finalStatusInfo(); QueryError error = results.getError(); checkState(error != null); out.printf("Query %s failed: %s%n", results.getId(), error.getMessage()); if (debug && (error.getFailureInfo() != null)) { error.getFailureInfo().toException().printStackTrace(out); } if (error.getErrorLocation() != null) { renderErrorLocation(client.getQuery(), error.getErrorLocation(), out); } out.println(); }
public void renderFailure(PrintStream out) { QueryResults results = client.finalResults(); QueryError error = results.getError(); checkState(error != null); out.printf("Query %s failed: %s%n", results.getId(), error.getMessage()); if (client.isDebug() && (error.getFailureInfo() != null)) { error.getFailureInfo().toException().printStackTrace(out); } if (error.getErrorLocation() != null) { renderErrorLocation(client.getQuery(), error.getErrorLocation(), out); } out.println(); }
@Description("Decodes json to an exception and throws it") @ScalarFunction @SqlType("unknown") public static void fail(@SqlType(StandardTypes.JSON) Slice failureInfoSlice) { FailureInfo failureInfo = JSON_CODEC.fromJson(failureInfoSlice.getBytes()); // wrap the failure in a new exception to append the current stack trace throw new PrestoException(StandardErrorCode.USER_ERROR, failureInfo.toException()); } }
RuntimeException remoteException = error.getFailureInfo().toException(); throw new RuntimeException(Optional.ofNullable(remoteException.getMessage()).orElseGet(remoteException::toString), remoteException);