class Main {

    public void errorHandling() {
        Routing routing = Routing.builder()
                                 .post("/compute", Handler.create(String.class, (req, res, str) -> {
                                     int result = 100 / Integer.parseInt(str);
                                     res.send(String.valueOf("100 / " + str + " = " + result));
                                 }))
                                 .error(Throwable.class, (req, res, ex) -> {
                                     ex.printStackTrace(System.out);
                                     req.next();
                                 })
                                 .error(NumberFormatException.class,
                                        (req, res, ex) -> res.status(Http.Status.BAD_REQUEST_400).send())
                                 .error(ArithmeticException.class,
                                        (req, res, ex) -> res.status(Http.Status.PRECONDITION_FAILED_412).send())
                                 .build();
        startServer(routing);
    }

}