use of com.palantir.logsafe.exceptions.SafeRuntimeException in project conjure-java by palantir.
the class ConjureUndertowAnnotationProcessorTest 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.createDirectories(output.getParent());
Files.write(output, generatedContents.getBytes(StandardCharsets.UTF_8));
}
assertThat(generatedContents).isEqualTo(Files.readString(output));
} catch (IOException e) {
throw new SafeRuntimeException(e);
}
}
use of com.palantir.logsafe.exceptions.SafeRuntimeException in project conjure-java-runtime-api by palantir.
the class ServiceExceptionTest method testErrorIdsAreInheritedFromRemoteExceptions.
@Test
public void testErrorIdsAreInheritedFromRemoteExceptions() {
RemoteException rootCause = new RemoteException(new SerializableError.Builder().errorCode("errorCode").errorName("errorName").build(), 500);
SafeRuntimeException intermediate = new SafeRuntimeException("Handled an exception", rootCause);
ServiceException parent = new ServiceException(ERROR, intermediate);
assertThat(parent.getErrorInstanceId()).isEqualTo(rootCause.getError().errorInstanceId());
}
use of com.palantir.logsafe.exceptions.SafeRuntimeException in project tracing-java by palantir.
the class OkhttpTraceInterceptor2 method intercept.
@Override
public Response intercept(Chain chain) throws IOException {
Request request = chain.request();
try (Closeable span = createNetworkCallSpan.apply(request)) {
if (!Tracer.hasTraceId()) {
throw new SafeRuntimeException("Trace with no spans in progress");
}
Request.Builder requestBuilder = request.newBuilder();
Tracers.addTracingHeaders(requestBuilder, EnrichingFunction.INSTANCE);
return chain.proceed(requestBuilder.build());
}
}
use of com.palantir.logsafe.exceptions.SafeRuntimeException in project atlasdb by palantir.
the class SafeShutdownRunner method throwIfFailures.
private void throwIfFailures() {
if (!failures.isEmpty()) {
RuntimeException closeFailed = new SafeRuntimeException("Close failed. Please inspect the code and fix the failures");
failures.forEach(closeFailed::addSuppressed);
failures.clear();
throw closeFailed;
}
}
use of com.palantir.logsafe.exceptions.SafeRuntimeException in project atlasdb by palantir.
the class ValidatingTransactionScopedCache method failAndLog.
private void failAndLog(Arg<?>... args) {
SafeRuntimeException runtimeException = new SafeRuntimeException("I exist to show you the stacktrace");
log.error("Reading from lock watch cache returned a different result to a remote read - this indicates there " + "is a corruption bug in the caching logic", Arrays.stream(args).collect(Collectors.toList()), runtimeException);
failureCallback.run();
throw new TransactionLockWatchFailedException("Failed lock watch cache validation - will retry without caching");
}
Aggregations