From 597033e623d27e3bab15b12f9a103e826d7c7ff7 Mon Sep 17 00:00:00 2001 From: Nidhi Date: Wed, 14 Jul 2021 11:36:25 +0530 Subject: [PATCH] Modified error message and code for authentication failure (#5810) --- .../exceptions/pluginExceptions/AppsmithPluginError.java | 2 ++ .../src/main/java/com/appsmith/external/models/OAuth2.java | 4 +--- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/app/server/appsmith-interfaces/src/main/java/com/appsmith/external/exceptions/pluginExceptions/AppsmithPluginError.java b/app/server/appsmith-interfaces/src/main/java/com/appsmith/external/exceptions/pluginExceptions/AppsmithPluginError.java index 9e3ad23fcd..8ed24cc472 100644 --- a/app/server/appsmith-interfaces/src/main/java/com/appsmith/external/exceptions/pluginExceptions/AppsmithPluginError.java +++ b/app/server/appsmith-interfaces/src/main/java/com/appsmith/external/exceptions/pluginExceptions/AppsmithPluginError.java @@ -25,6 +25,8 @@ public enum AppsmithPluginError { AppsmithErrorAction.LOG_EXTERNALLY, "Datasource configuration is invalid"), PLUGIN_DATASOURCE_TIMEOUT_ERROR(504, 5008, "{0}", AppsmithErrorAction.DEFAULT, "Timed out when connecting to " + "datasource"), + PLUGIN_AUTHENTICATION_ERROR(401, 4000, "Invalid authentication credentials. Please check datasource configuration.", + AppsmithErrorAction.DEFAULT, "Datasource authentication error"), ; private final Integer httpErrorCode; diff --git a/app/server/appsmith-interfaces/src/main/java/com/appsmith/external/models/OAuth2.java b/app/server/appsmith-interfaces/src/main/java/com/appsmith/external/models/OAuth2.java index 96c35dedb4..d04c1bf71c 100644 --- a/app/server/appsmith-interfaces/src/main/java/com/appsmith/external/models/OAuth2.java +++ b/app/server/appsmith-interfaces/src/main/java/com/appsmith/external/models/OAuth2.java @@ -85,9 +85,7 @@ public class OAuth2 extends AuthenticationDTO { @Override public Mono hasExpired() { if (this.authenticationResponse == null) { - return Mono.error(new AppsmithPluginException( - AppsmithPluginError.PLUGIN_ERROR, - "Expected datasource to have valid authentication tokens at this point")); + return Mono.error(new AppsmithPluginException(AppsmithPluginError.PLUGIN_AUTHENTICATION_ERROR)); } if (this.authenticationResponse.expiresAt == null) {