use of com.palantir.logsafe.exceptions.SafeRuntimeException in project dialogue by palantir.
the class DialogueRequestAnnotationsProcessorTest method assertContentsMatch.
private void assertContentsMatch(JavaFileObject javaFileObject, String generatedClassFile) {
try {
Path output = RESOURCES_BASE_DIR.resolve(generatedClassFile + ".generated");
String generatedContents = readJavaFileObject(javaFileObject);
if (DEV_MODE) {
Files.deleteIfExists(output);
Files.write(output, generatedContents.getBytes(StandardCharsets.UTF_8));
}
assertThat(generatedContents).isEqualTo(readFromFile(output));
} catch (IOException e) {
throw new SafeRuntimeException(e);
}
}
use of com.palantir.logsafe.exceptions.SafeRuntimeException in project foundry-athena-query-federation-connector by palantir.
the class S3Spiller method makeSpillLocation.
private S3SpillLocation makeSpillLocation() {
S3SpillLocation splitSpillLocation = (S3SpillLocation) spillConfig.getSpillLocation();
if (!splitSpillLocation.isDirectory()) {
throw new SafeRuntimeException("Split's SpillLocation must be a directory because multiple blocks may be spilled.");
}
String blockKey = splitSpillLocation.getKey() + "." + spillNumber.getAndIncrement();
return new S3SpillLocation(splitSpillLocation.getBucket(), blockKey, false);
}
use of com.palantir.logsafe.exceptions.SafeRuntimeException in project tracing-java by palantir.
the class TracersTest method testWrapFuture_throws.
@Test
public void testWrapFuture_throws() {
List<Span> observed = new ArrayList<>();
Tracer.subscribe("futureTest", observed::add);
try {
String operationName = "testOperation";
assertThatThrownBy(() -> Tracers.wrapListenableFuture(operationName, () -> {
// wild so we must handle them properly.
throw new SafeRuntimeException("initial operation failure");
})).isInstanceOf(SafeRuntimeException.class).hasMessage("initial operation failure");
assertThat(observed).hasSize(1);
assertThat(observed.get(0)).extracting(Span::getOperation).isEqualTo(operationName);
assertThat(observed).allSatisfy(span -> assertThat(span).extracting(Span::getTraceId).isEqualTo("defaultTraceId"));
} finally {
Tracer.unsubscribe("futureTest");
}
}
use of com.palantir.logsafe.exceptions.SafeRuntimeException in project conjure-java-runtime-api by palantir.
the class ServiceExceptionTest method testErrorIdsAreInheritedFromServiceExceptions.
@Test
public void testErrorIdsAreInheritedFromServiceExceptions() {
ServiceException rootCause = new ServiceException(ERROR);
SafeRuntimeException intermediate = new SafeRuntimeException("Handled an exception", rootCause);
ServiceException parent = new ServiceException(ERROR, intermediate);
assertThat(parent.getErrorInstanceId()).isEqualTo(rootCause.getErrorInstanceId());
}
use of com.palantir.logsafe.exceptions.SafeRuntimeException in project dialogue by palantir.
the class RetryingChannelTest method doesNotRetryRuntimeException.
@Test
public void doesNotRetryRuntimeException() {
when(channel.execute(any())).thenReturn(Futures.immediateFailedFuture(new SafeRuntimeException("bug"))).thenReturn(SUCCESS);
EndpointChannel retryer = new RetryingChannel(channel, TestEndpoint.POST, "my-channel", 1, Duration.ZERO, ClientConfiguration.ServerQoS.AUTOMATIC_RETRY, ClientConfiguration.RetryOnTimeout.DISABLED);
ListenableFuture<Response> response = retryer.execute(REQUEST);
assertThatThrownBy(response::get).hasRootCauseExactlyInstanceOf(SafeRuntimeException.class).hasRootCauseMessage("bug");
}
Aggregations