diff --git a/carstore/pom.xml b/carstore/pom.xml
index f94a0014..07827e17 100644
--- a/carstore/pom.xml
+++ b/carstore/pom.xml
@@ -5,7 +5,7 @@
com.gwtplatform
carstore
- 1.5
+ 1.6-SNAPSHOT
war
GWTP Carstore
Simple application used for testing GWTP features.
@@ -13,7 +13,7 @@
2.7.0
- 1.5
+ 1.6-SNAPSHOT
2.1.2
1.4.2
1.2.1
@@ -41,8 +41,8 @@
0.9.6
3.2
2.1
- 2.18
- 2.18
+ 2.18.1
+ 2.18.1
2.7.0
2.14
diff --git a/carstore/src/main/java/com/gwtplatform/carstore/client/dispatch/DispatchExceptionHandler.java b/carstore/src/main/java/com/gwtplatform/carstore/client/dispatch/DispatchExceptionHandler.java
new file mode 100644
index 00000000..d118bdcc
--- /dev/null
+++ b/carstore/src/main/java/com/gwtplatform/carstore/client/dispatch/DispatchExceptionHandler.java
@@ -0,0 +1,81 @@
+/*
+ * Copyright 2015 ArcBees Inc.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not
+ * use this file except in compliance with the License. You may obtain a copy of
+ * the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations under
+ * the License.
+ */
+
+package com.gwtplatform.carstore.client.dispatch;
+
+import javax.inject.Inject;
+import javax.inject.Provider;
+
+import com.gwtplatform.carstore.client.application.ApplicationPresenter;
+import com.gwtplatform.carstore.client.application.event.DisplayMessageEvent;
+import com.gwtplatform.carstore.client.application.widget.message.Message;
+import com.gwtplatform.carstore.client.application.widget.message.MessageStyle;
+import com.gwtplatform.dispatch.client.ExceptionHandler;
+import com.gwtplatform.dispatch.rest.shared.ActionResponseException;
+import com.gwtplatform.dispatch.rest.shared.RestActionException;
+import com.gwtplatform.dispatch.shared.ActionException;
+
+public class DispatchExceptionHandler implements ExceptionHandler {
+
+ private final Provider appPresenterProvider;
+
+ @Inject
+ DispatchExceptionHandler(Provider appPresenterProvider) {
+ this.appPresenterProvider = appPresenterProvider;
+ }
+
+ @Override
+ public Status onFailure(Throwable e) {
+ if (e instanceof ActionException) {
+ return handleActionExceptions((ActionException) e);
+ }
+
+ return Status.CONTINUE;
+ }
+
+ private Status handleActionExceptions(ActionException e) {
+ Status status;
+ if (e instanceof RestActionException) {
+ // This is a REST action exception
+ status = handleRestActionExceptions((RestActionException) e);
+ } else {
+ // This is an RPC action exception
+ status = handleRpcActionExceptions(e);
+ }
+
+ return status;
+ }
+
+ private Status handleRestActionExceptions(RestActionException e) {
+ Status status = Status.CONTINUE;
+
+ if (e instanceof ActionResponseException) {
+ // Unauthorized access exception
+ if (((ActionResponseException) e).getStatusCode() == 401) {
+ DisplayMessageEvent.fire(appPresenterProvider.get(), new Message(
+ "You do not have access to this part of the system.", MessageStyle.ERROR));
+
+ status = Status.STOP;
+ }
+ }
+
+ return status;
+ }
+
+ private Status handleRpcActionExceptions(ActionException e) {
+ return Status.CONTINUE;
+ }
+}
diff --git a/carstore/src/main/java/com/gwtplatform/carstore/client/gin/SharedModule.java b/carstore/src/main/java/com/gwtplatform/carstore/client/gin/SharedModule.java
index d9aee543..a9a11f8e 100644
--- a/carstore/src/main/java/com/gwtplatform/carstore/client/gin/SharedModule.java
+++ b/carstore/src/main/java/com/gwtplatform/carstore/client/gin/SharedModule.java
@@ -16,6 +16,7 @@
package com.gwtplatform.carstore.client.gin;
+import com.gwtplatform.carstore.client.dispatch.DispatchExceptionHandler;
import com.gwtplatform.carstore.client.dispatch.rest.AppRestDispatchHooks;
import com.gwtplatform.carstore.client.dispatch.rest.RestInterceptorRegistry;
import com.gwtplatform.carstore.client.dispatch.rpc.AppRpcDispatchHooks;
@@ -39,10 +40,12 @@ protected void configure() {
install(new RestDispatchAsyncModule.Builder()
.dispatchHooks(AppRestDispatchHooks.class)
.interceptorRegistry(RestInterceptorRegistry.class)
+ .exceptionHandler(DispatchExceptionHandler.class)
.build());
install(new RpcDispatchAsyncModule.Builder()
.dispatchHooks(AppRpcDispatchHooks.class)
.interceptorRegistry(RpcInterceptorRegistry.class)
+ .exceptionHandler(DispatchExceptionHandler.class)
.build());
// CarStore modules
diff --git a/carstore/src/main/java/com/gwtplatform/carstore/server/dispatch/LogInHandler.java b/carstore/src/main/java/com/gwtplatform/carstore/server/dispatch/LogInHandler.java
index 21240a85..6441add5 100644
--- a/carstore/src/main/java/com/gwtplatform/carstore/server/dispatch/LogInHandler.java
+++ b/carstore/src/main/java/com/gwtplatform/carstore/server/dispatch/LogInHandler.java
@@ -68,9 +68,9 @@ public LogInResult execute(LogInAction action, ExecutionContext context) throws
loggedInCookie = loginCookieDao.createSessionCookie(userDto);
}
- logger.info("LogInHandlerexecut(): actiontype=" + getActionType());
- logger.info("LogInHandlerexecut(): currentUserDto=" + currentUserDto);
- logger.info("LogInHandlerexecut(): loggedInCookie=" + loggedInCookie);
+ logger.info("LogInHandler#execute(): actiontype=" + getActionType());
+ logger.info("LogInHandler#execute(): currentUserDto=" + currentUserDto);
+ logger.info("LogInHandler#execute(): loggedInCookie=" + loggedInCookie);
return new LogInResult(action.getActionType(), currentUserDto, loggedInCookie);
}