@OnError
  public void errorHandle(Session session, Throwable error) {
    if (session != null && session.isOpen()) {
      WebsocketMessageWrapper<Error> response = new WebsocketMessageWrapper<>();
      response.setType(WebsocketMessageType.CUSTOMER_ERROR);
      response.setData(new Error());
      if (error instanceof CustomerNotFoundException) {
        response.setSequenceId(((CustomerNotFoundException) error).getSequenceId());
        response.getData().setCode("customer.notFound");
        response.getData().setDescription("Customer not found");
      } else {
        WebSocketServerLogger.LOG.handleWebsocketServerError(error);

        response.setSequenceId(UUID.randomUUID().toString());
        response.getData().setCode(error.getClass().getName());
        response.getData().setDescription("Handled exception");
      }

      session.getAsyncRemote().sendObject(response);
    }
  }
Exemple #2
0
 @OnError
 public void onError(Throwable t) {
   t.printStackTrace();
 }
 @OnError
 public void onError(Throwable error) {
   logger.warning(error.getMessage());
   logger.info("Something went bad");
 }
 @OnError
 public void myError(Throwable t) {
   System.out.println("Error: " + t.getMessage());
 }