public RuntimeException toException() { return toException(this); }
private static RuntimeException getCause(QueryError queryError) { if (queryError.getFailureInfo() != null) { return queryError.getFailureInfo().toException(); } return null; }
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(); }
@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);
QueryError queryError = new QueryError( Optional.ofNullable(error.getFailureInfo().getMessage()) .orElse(error.getFailureInfo().toException().toString()), error.getSqlState(), error.getErrorCode(),
public RuntimeException toException() { return toException(this); }
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 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);