@Test public void shouldLeaveOneStrippedNestedException () { RaygunStripWrappedExceptionFilter f = new RaygunStripWrappedExceptionFilter(ClassNotFoundException.class, IllegalStateException.class); RaygunMessage message = new RaygunMessage(); message.getDetails().setError(new RaygunErrorMessage(new ClassNotFoundException("wrapper1", new ClassNotFoundException("wrapper2", new IllegalStateException("wrapper3"))))); f.onBeforeSend(null, message); assertThat(message.getDetails().getError().getMessage(), is("IllegalStateException: wrapper3")); }
public RaygunMessage onBeforeSend(RaygunClient client, RaygunMessage message) { if(message.getDetails() != null && message.getDetails().getError() != null && message.getDetails().getError().getInnerError() != null && message.getDetails().getError().getThrowable() != null) { for (Class<?> stripClass : stripClasses) { if (stripClass.isAssignableFrom(message.getDetails().getError().getThrowable().getClass())) { RaygunErrorMessage innerError = message.getDetails().getError().getInnerError(); message.getDetails().setError(innerError); onBeforeSend(client, message); return message; } } } return message; }
RaygunStripWrappedExceptionFilter implements IRaygunOnBeforeSend, IRaygunSendEventFactory<IRaygunOnBeforeSend> { public RaygunMessage onBeforeSend(RaygunClient client, RaygunMessage message) { if(message.getDetails() != null && message.getDetails().getError() != null && message.getDetails().getError().getInnerError() != null && message.getDetails().getError().getThrowable() != null) { for (Class<?> stripClass : stripClasses) { if (stripClass.isAssignableFrom(message.getDetails().getError().getThrowable().getClass())) { RaygunErrorMessage innerError = message.getDetails().getError().getInnerError(); message.getDetails().setError(innerError); onBeforeSend(client, message); return message; } } } return message; } }
RaygunStripWrappedExceptionFilter implements IRaygunOnBeforeSend, IRaygunSendEventFactory<IRaygunOnBeforeSend> { public RaygunMessage onBeforeSend(RaygunClient client, RaygunMessage message) { if(message.getDetails() != null && message.getDetails().getError() != null && message.getDetails().getError().getInnerError() != null && message.getDetails().getError().getThrowable() != null) { for (Class<?> stripClass : stripClasses) { if (stripClass.isAssignableFrom(message.getDetails().getError().getThrowable().getClass())) { RaygunErrorMessage innerError = message.getDetails().getError().getInnerError(); message.getDetails().setError(innerError); onBeforeSend(client, message); return message; } } } return message; } RaygunStripWrappedExceptionFilter(Class<?>... stripClasses); }
RaygunStripWrappedExceptionFilter implements IRaygunOnBeforeSend, IRaygunSendEventFactory<IRaygunOnBeforeSend> { public RaygunMessage onBeforeSend(RaygunClient client, RaygunMessage message) { if(message.getDetails() != null && message.getDetails().getError() != null && message.getDetails().getError().getInnerError() != null && message.getDetails().getError().getThrowable() != null) { for (Class<?> stripClass : stripClasses) { if (stripClass.isAssignableFrom(message.getDetails().getError().getThrowable().getClass())) { RaygunErrorMessage innerError = message.getDetails().getError().getInnerError(); message.getDetails().setError(innerError); onBeforeSend(client, message); return message; } } } return message; } RaygunStripWrappedExceptionFilter(Class<?>... stripClasses); RaygunMessage onBeforeSend(RaygunClient client, RaygunMessage message); IRaygunOnBeforeSend create(); }
RaygunStripWrappedExceptionFilter implements IRaygunOnBeforeSend, IRaygunSendEventFactory<IRaygunOnBeforeSend> { public RaygunMessage onBeforeSend(RaygunClient client, RaygunMessage message) { if(message.getDetails() != null && message.getDetails().getError() != null && message.getDetails().getError().getInnerError() != null && message.getDetails().getError().getThrowable() != null) { for (Class<?> stripClass : stripClasses) { if (stripClass.isAssignableFrom(message.getDetails().getError().getThrowable().getClass())) { RaygunErrorMessage innerError = message.getDetails().getError().getInnerError(); message.getDetails().setError(innerError); onBeforeSend(client, message); return message; } } } return message; } RaygunStripWrappedExceptionFilter(Class<?>... stripClasses); RaygunMessage onBeforeSend(RaygunClient client, RaygunMessage message); IRaygunOnBeforeSend create();  }