Search in sources :

Example 1 with SafeRuntimeException

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);
    }
}
Also used : Path(java.nio.file.Path) SafeRuntimeException(com.palantir.logsafe.exceptions.SafeRuntimeException) IOException(java.io.IOException)

Example 2 with SafeRuntimeException

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());
}
Also used : SafeRuntimeException(com.palantir.logsafe.exceptions.SafeRuntimeException) Test(org.junit.jupiter.api.Test)

Example 3 with SafeRuntimeException

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());
    }
}
Also used : SafeRuntimeException(com.palantir.logsafe.exceptions.SafeRuntimeException) Closeable(java.io.Closeable) Request(okhttp3.Request)

Example 4 with SafeRuntimeException

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;
    }
}
Also used : SafeRuntimeException(com.palantir.logsafe.exceptions.SafeRuntimeException) SafeRuntimeException(com.palantir.logsafe.exceptions.SafeRuntimeException)

Example 5 with SafeRuntimeException

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");
}
Also used : SafeRuntimeException(com.palantir.logsafe.exceptions.SafeRuntimeException) TransactionLockWatchFailedException(com.palantir.atlasdb.transaction.api.TransactionLockWatchFailedException)

Aggregations

SafeRuntimeException (com.palantir.logsafe.exceptions.SafeRuntimeException)43 IOException (java.io.IOException)13 Test (org.junit.jupiter.api.Test)7 Path (java.nio.file.Path)6 Response (com.palantir.dialogue.Response)5 ImmutableMap (com.google.common.collect.ImmutableMap)3 TestResponse (com.palantir.dialogue.TestResponse)3 DefaultInvocationContext (com.palantir.tritium.event.DefaultInvocationContext)3 InvocationContext (com.palantir.tritium.event.InvocationContext)3 File (java.io.File)3 InputStream (java.io.InputStream)3 ArrayList (java.util.ArrayList)3 Test (org.junit.Test)3 ImmutableList (com.google.common.collect.ImmutableList)2 ListenableFuture (com.google.common.util.concurrent.ListenableFuture)2 Value (com.palantir.atlasdb.keyvalue.api.Value)2 DisableNamespacesResponse (com.palantir.atlasdb.timelock.api.DisableNamespacesResponse)2 SuccessfulDisableNamespacesResponse (com.palantir.atlasdb.timelock.api.SuccessfulDisableNamespacesResponse)2 UnsuccessfulDisableNamespacesResponse (com.palantir.atlasdb.timelock.api.UnsuccessfulDisableNamespacesResponse)2 Channel (com.palantir.dialogue.Channel)2