  @Test
  public void shouldSendErrorsFromConsumerToMobiusHooks() throws Exception {

    // given an error handler
    TestErrorHandler errorHandler = new TestErrorHandler();

    MobiusHooks.setErrorHandler(errorHandler);

    final RuntimeException expected = new RuntimeException("boo");

    // and a message consumer that throws an exception,
    // when a message is dispatched
    new MessageDispatcher<String>(
            WorkRunners.immediate(),
            s -> {
              throw expected;
            })
        .accept("here's an event that should be reported as the cause of failure");

    // then the exception gets sent to the error handler.
    assertThat(errorHandler.handledErrors).extracting(Throwable::getCause).contains(expected);
    assertThat(errorHandler.handledErrors)
        .extracting(Throwable::getMessage)
        .has(
            matching(
                containsString("here's an event that should be reported as the cause of failure")),
            atIndex(0));
  }