From 4dd76de22bd944e2d034f495a90450737cce5f93 Mon Sep 17 00:00:00 2001 From: Gustavo Martin Morcuende Date: Sun, 1 Jan 2017 17:23:47 +0100 Subject: [PATCH] Thought about Exceptions, RxJava and Spring --- .../rest/business/service/impl/AwesomeBusinessLogicImpl.java | 9 +++++++++ .../rest/business/service/impl/RxJavaBusinessLogicImpl.java | 2 ++ 2 files changed, 11 insertions(+) diff --git a/SpringJava/RxJava/web-services-spring-rxjava-server/src/main/java/de/spring/webservices/rest/business/service/impl/AwesomeBusinessLogicImpl.java b/SpringJava/RxJava/web-services-spring-rxjava-server/src/main/java/de/spring/webservices/rest/business/service/impl/AwesomeBusinessLogicImpl.java index 5c960fe..37da05a 100644 --- a/SpringJava/RxJava/web-services-spring-rxjava-server/src/main/java/de/spring/webservices/rest/business/service/impl/AwesomeBusinessLogicImpl.java +++ b/SpringJava/RxJava/web-services-spring-rxjava-server/src/main/java/de/spring/webservices/rest/business/service/impl/AwesomeBusinessLogicImpl.java @@ -21,6 +21,13 @@ public class AwesomeBusinessLogicImpl implements AwesomeBusinessLogic { @Override public Page findAll(Pageable pageRequest) { + + // It seems like calling Exceptions.propagate(ex) in RxJava code is only required + // for no RuntimeExceptions (for catchable exceptions) + // Spring will see this exception :) + // So no catchable exceptions do not require anything at all for being seen by Spring :) + // throw new RuntimeException("createThrowable FATAL ERROR"); + final List cars = new ArrayList<>(); cars.add(new Car(counter.incrementAndGet(), String.format(TEMPLATE, 1))); cars.add(new Car(counter.incrementAndGet(), String.format(TEMPLATE, 2))); @@ -68,6 +75,8 @@ public class AwesomeBusinessLogicImpl implements AwesomeBusinessLogic { // Spring sees both exceptions. // It seems like calling Exceptions.propagate(ex) in RxJava code is only required // for no RuntimeExceptions :/ + // Spring will see this exception :) + // So no catchable exceptions do not require anything at all for being seen by Spring :) // throw new RuntimeException("createThrowable FATAL ERROR"); } } diff --git a/SpringJava/RxJava/web-services-spring-rxjava-server/src/main/java/de/spring/webservices/rest/business/service/impl/RxJavaBusinessLogicImpl.java b/SpringJava/RxJava/web-services-spring-rxjava-server/src/main/java/de/spring/webservices/rest/business/service/impl/RxJavaBusinessLogicImpl.java index 771fb40..d18ae31 100644 --- a/SpringJava/RxJava/web-services-spring-rxjava-server/src/main/java/de/spring/webservices/rest/business/service/impl/RxJavaBusinessLogicImpl.java +++ b/SpringJava/RxJava/web-services-spring-rxjava-server/src/main/java/de/spring/webservices/rest/business/service/impl/RxJavaBusinessLogicImpl.java @@ -83,6 +83,8 @@ public class RxJavaBusinessLogicImpl implements RxJavaBusinessLogic { LOGGER.error("createThrowable error: ", ex); + // This method is only required when wrapping catchable exceptions. + // RuntimeExceptions do not require this stuff and they are seen by Spring MVC. Exceptions.propagate(ex); } -- 2.1.4