void throwExceptionIfNotSuccessfullyDecoded(HttpObject httpObject) { Throwable decoderFailure = getDecoderFailure(httpObject); if (decoderFailure == null) { return; } throw new InvalidHttpRequestException( "Detected HttpObject that was not successfully decoded.", decoderFailure ); }
Throwable cause = theEx.getCause();
void throwExceptionIfNotSuccessfullyDecoded(HttpObject httpObject) { Throwable decoderFailure = getDecoderFailure(httpObject); if (decoderFailure == null) { return; } throw new InvalidHttpRequestException( "Detected HttpObject that was not successfully decoded.", decoderFailure ); }
@Test public void shouldHandleInvalidHttpRequestExceptionWithNullCause() { ApiExceptionHandlerListenerResult result = listener.shouldHandleException(new InvalidHttpRequestException("message", null)); assertThat(result.shouldHandleResponse).isTrue(); assertThat(result.errors).isEqualTo(singletonError( new ApiErrorWithMetadata(testProjectApiErrors.getMalformedRequestApiError(), Pair.of("cause", "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("exception_cause_details"); assertThat(result.extraDetailsForLogging.get(1).getRight()).isEqualTo("NO_CAUSE"); }
new InvalidHttpRequestException(outerExceptionMessage, cause) );
@DataProvider(value = { "NORMAL_TOO_LONG_HEADERS_ERROR | true", "NORMAL_TOO_LONG_HEADERS_ERROR | false", "NORMAL_TOO_LONG_LINE_ERROR | true", "NORMAL_TOO_LONG_LINE_ERROR | false", "NULL_EXCEPTION_MESSAGE | true", "NULL_EXCEPTION_MESSAGE | false", "EXCEPTION_MESSAGE_DOES_NOT_END_IN_BYTES | true", "EXCEPTION_MESSAGE_DOES_NOT_END_IN_BYTES | false", "HEADER_EXCEPTION_MESSAGE_MAX_SIZE_NOT_AN_INTEGER | true", "HEADER_EXCEPTION_MESSAGE_MAX_SIZE_NOT_AN_INTEGER | false", "LINE_EXCEPTION_MESSAGE_MAX_SIZE_NOT_AN_INTEGER | true", "LINE_EXCEPTION_MESSAGE_MAX_SIZE_NOT_AN_INTEGER | false" }, splitBy = "\\|") @Test public void should_handle_TooLongFrameException_as_expected( TooLongFrameExceptionScenario scenario, boolean wrappedInInvalidHttpRequestException ) { Throwable ex = (wrappedInInvalidHttpRequestException) ? new InvalidHttpRequestException("foo", scenario.exception) : scenario.exception; verifyExceptionHandled( ex, singletonError(scenario.expectedApiError(listener)) ); }