Search in sources :

Example 1 with ApiExceptionHandlerListenerResult

use of com.nike.backstopper.handler.listener.ApiExceptionHandlerListenerResult in project riposte by Nike-Inc.

the class BackstopperRiposteFrameworkErrorHandlerListenerTest method verifyExceptionHandled.

private void verifyExceptionHandled(Throwable ex, SortedApiErrorSet expectedErrors) {
    ApiExceptionHandlerListenerResult result = listener.shouldHandleException(ex);
    assertThat(result.shouldHandleResponse).isTrue();
    assertThat(result.errors).isEqualTo(expectedErrors);
}
Also used : ApiExceptionHandlerListenerResult(com.nike.backstopper.handler.listener.ApiExceptionHandlerListenerResult)

Example 2 with ApiExceptionHandlerListenerResult

use of com.nike.backstopper.handler.listener.ApiExceptionHandlerListenerResult in project riposte by Nike-Inc.

the class BackstopperRiposteFrameworkErrorHandlerListenerTest method shouldHandleInvalidHttpRequestExceptionWithNullCause.

@Test
public void shouldHandleInvalidHttpRequestExceptionWithNullCause() {
    ApiExceptionHandlerListenerResult result = listener.shouldHandleException(new InvalidHttpRequestException("message", null));
    assertThat(result.shouldHandleResponse).isTrue();
    assertThat(result.errors).isEqualTo(singletonError(testProjectApiErrors.getMalformedRequestApiError()));
    assertThat(result.errors.first().getMetadata().get("cause")).isEqualTo("Invalid HTTP request");
    assertThat(result.extraDetailsForLogging.get(0).getLeft()).isEqualTo("exception_message");
    assertThat(result.extraDetailsForLogging.get(0).getRight()).isEqualTo("message");
    assertThat(result.extraDetailsForLogging.get(1).getLeft()).isEqualTo("cause_details");
    assertThat(result.extraDetailsForLogging.get(1).getRight()).isEqualTo("null");
}
Also used : InvalidHttpRequestException(com.nike.riposte.server.error.exception.InvalidHttpRequestException) ApiExceptionHandlerListenerResult(com.nike.backstopper.handler.listener.ApiExceptionHandlerListenerResult) Test(org.junit.Test)

Example 3 with ApiExceptionHandlerListenerResult

use of com.nike.backstopper.handler.listener.ApiExceptionHandlerListenerResult in project riposte by Nike-Inc.

the class BackstopperRiposteFrameworkErrorHandlerListenerTest method shouldIgnoreUnhandledErrors.

@Test
public void shouldIgnoreUnhandledErrors() {
    ApiExceptionHandlerListenerResult result = listener.shouldHandleException(new Exception());
    assertThat(result.shouldHandleResponse).isFalse();
}
Also used : ApiExceptionHandlerListenerResult(com.nike.backstopper.handler.listener.ApiExceptionHandlerListenerResult) Forbidden403Exception(com.nike.riposte.server.error.exception.Forbidden403Exception) MethodNotAllowed405Exception(com.nike.riposte.server.error.exception.MethodNotAllowed405Exception) CircuitBreakerOpenException(com.nike.fastbreak.exception.CircuitBreakerOpenException) CircuitBreakerTimeoutException(com.nike.fastbreak.exception.CircuitBreakerTimeoutException) InvalidCharsetInContentTypeHeaderException(com.nike.riposte.server.error.exception.InvalidCharsetInContentTypeHeaderException) InvalidHttpRequestException(com.nike.riposte.server.error.exception.InvalidHttpRequestException) ErrorDataDecoderException(io.netty.handler.codec.http.multipart.HttpPostRequestDecoder.ErrorDataDecoderException) PathParameterMatchingException(com.nike.riposte.server.error.exception.PathParameterMatchingException) IncompleteHttpCallTimeoutException(com.nike.riposte.server.error.exception.IncompleteHttpCallTimeoutException) RequestContentDeserializationException(com.nike.riposte.server.error.exception.RequestContentDeserializationException) CircuitBreakerException(com.nike.fastbreak.exception.CircuitBreakerException) DownstreamIdleChannelTimeoutException(com.nike.riposte.server.error.exception.DownstreamIdleChannelTimeoutException) HostnameResolutionException(com.nike.riposte.server.error.exception.HostnameResolutionException) DownstreamChannelClosedUnexpectedlyException(com.nike.riposte.server.error.exception.DownstreamChannelClosedUnexpectedlyException) TooLongFrameException(io.netty.handler.codec.TooLongFrameException) TooManyOpenChannelsException(com.nike.riposte.server.error.exception.TooManyOpenChannelsException) Unauthorized401Exception(com.nike.riposte.server.error.exception.Unauthorized401Exception) MultipleMatchingEndpointsException(com.nike.riposte.server.error.exception.MultipleMatchingEndpointsException) PathNotFound404Exception(com.nike.riposte.server.error.exception.PathNotFound404Exception) Test(org.junit.Test)

Example 4 with ApiExceptionHandlerListenerResult

use of com.nike.backstopper.handler.listener.ApiExceptionHandlerListenerResult in project riposte by Nike-Inc.

the class BackstopperRiposteFrameworkErrorHandlerListenerTest method shouldHandleInvalidHttpRequestExceptionWithNonNullCause.

@Test
public void shouldHandleInvalidHttpRequestExceptionWithNonNullCause() {
    ApiExceptionHandlerListenerResult result = listener.shouldHandleException(new InvalidHttpRequestException("message", new RuntimeException("runtime exception")));
    assertThat(result.shouldHandleResponse).isTrue();
    assertThat(result.errors).isEqualTo(singletonError(testProjectApiErrors.getMalformedRequestApiError()));
    assertThat(result.errors.first().getMetadata().get("cause")).isEqualTo("Invalid HTTP request");
    assertThat(result.extraDetailsForLogging.get(0).getLeft()).isEqualTo("exception_message");
    assertThat(result.extraDetailsForLogging.get(0).getRight()).isEqualTo("message");
    assertThat(result.extraDetailsForLogging.get(1).getLeft()).isEqualTo("cause_details");
    assertThat(result.extraDetailsForLogging.get(1).getRight()).isEqualTo("java.lang.RuntimeException: runtime exception");
}
Also used : InvalidHttpRequestException(com.nike.riposte.server.error.exception.InvalidHttpRequestException) ApiExceptionHandlerListenerResult(com.nike.backstopper.handler.listener.ApiExceptionHandlerListenerResult) Test(org.junit.Test)

Example 5 with ApiExceptionHandlerListenerResult

use of com.nike.backstopper.handler.listener.ApiExceptionHandlerListenerResult in project riposte by Nike-Inc.

the class BackstopperRiposteFrameworkErrorHandlerListenerTest method shouldHandleTooLongFrameExceptionAndAddCauseMetadata.

@Test
public void shouldHandleTooLongFrameExceptionAndAddCauseMetadata() {
    ApiExceptionHandlerListenerResult result = listener.shouldHandleException(new TooLongFrameException());
    assertThat(result.shouldHandleResponse).isTrue();
    assertThat(result.errors).isEqualTo(singletonError(testProjectApiErrors.getMalformedRequestApiError()));
    assertThat(result.errors.first().getMetadata().get("cause")).isEqualTo("The request exceeded the maximum payload size allowed");
}
Also used : TooLongFrameException(io.netty.handler.codec.TooLongFrameException) ApiExceptionHandlerListenerResult(com.nike.backstopper.handler.listener.ApiExceptionHandlerListenerResult) Test(org.junit.Test)

Aggregations

ApiExceptionHandlerListenerResult (com.nike.backstopper.handler.listener.ApiExceptionHandlerListenerResult)5 Test (org.junit.Test)4 InvalidHttpRequestException (com.nike.riposte.server.error.exception.InvalidHttpRequestException)3 TooLongFrameException (io.netty.handler.codec.TooLongFrameException)2 CircuitBreakerException (com.nike.fastbreak.exception.CircuitBreakerException)1 CircuitBreakerOpenException (com.nike.fastbreak.exception.CircuitBreakerOpenException)1 CircuitBreakerTimeoutException (com.nike.fastbreak.exception.CircuitBreakerTimeoutException)1 DownstreamChannelClosedUnexpectedlyException (com.nike.riposte.server.error.exception.DownstreamChannelClosedUnexpectedlyException)1 DownstreamIdleChannelTimeoutException (com.nike.riposte.server.error.exception.DownstreamIdleChannelTimeoutException)1 Forbidden403Exception (com.nike.riposte.server.error.exception.Forbidden403Exception)1 HostnameResolutionException (com.nike.riposte.server.error.exception.HostnameResolutionException)1 IncompleteHttpCallTimeoutException (com.nike.riposte.server.error.exception.IncompleteHttpCallTimeoutException)1 InvalidCharsetInContentTypeHeaderException (com.nike.riposte.server.error.exception.InvalidCharsetInContentTypeHeaderException)1 MethodNotAllowed405Exception (com.nike.riposte.server.error.exception.MethodNotAllowed405Exception)1 MultipleMatchingEndpointsException (com.nike.riposte.server.error.exception.MultipleMatchingEndpointsException)1 PathNotFound404Exception (com.nike.riposte.server.error.exception.PathNotFound404Exception)1 PathParameterMatchingException (com.nike.riposte.server.error.exception.PathParameterMatchingException)1 RequestContentDeserializationException (com.nike.riposte.server.error.exception.RequestContentDeserializationException)1 TooManyOpenChannelsException (com.nike.riposte.server.error.exception.TooManyOpenChannelsException)1 Unauthorized401Exception (com.nike.riposte.server.error.exception.Unauthorized401Exception)1