title: Handling exception with Mono flow
body: <p>I have a WebFlux handler as below.</p>
  <pre><code>@Transactional
    public Mono&lt;ServerResponse&gt; submitOrder(final ServerRequest request) {
      return context.retrieveUser().flatMap(usr -&gt; {
        try {
          return Mono.zip(branchSetting, labOrderDetail, labOrderTests).flatMap(response -&gt; {
            final Mono&lt;String&gt; submitOrderMono = service.submitOrder(usr);
            final Mono&lt;Integer&gt; updateStatusMono = orderRepository.updateStatus(orderId);
            return Mono.zip(submitOrderMono, updateStatusMono).flatMap(submitResponse -&gt; {
              return ok().bodyValue(submitResponse.getT1());
            }).onErrorResume(e -&gt; {
              if (e instanceof ServiceException) {
                ServiceException ex = (ServiceException) e;
                return status(ex.getStatusCode()).bodyValue(e.getMessage());
              } else {
                return status(500).bodyValue(e.getMessage());
              }
            });
          });
        } catch (Throwable e) {
          if (e instanceof ServiceException) {
            ServiceException ex = (ServiceException) e;
            return status(ex.getStatusCode()).bodyValue(e.getMessage());
          } else {
            return status(500).bodyValue(e.getMessage());
          }
        }
      });
    }
  </code></pre>
  <p>submitOrder method from service class,</p>
  <pre><code>public Mono&lt;String&gt; submitOrder(final Order order,
        if (order.getPatientId() != null) {
          throw new ServiceException(&quot;Missing Id for patient !!!&quot;, HttpStatus.BAD_REQUEST.value());
        }
    }
  </code></pre>
  <p>Here, I am doing some validation and throwing Exception.</p>
  <p>But, this exception is not getting into onErrorResume or catch block in the calling main method and hence the service caller sees 500 error.</p>
  <p>Not sure what is wrong here.</p>