You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@dolphinscheduler.apache.org by ca...@apache.org on 2022/04/06 01:17:38 UTC

[dolphinscheduler] branch dev updated: [Improvement-9338][API] show more create datasource exception message (#9336)

This is an automated email from the ASF dual-hosted git repository.

caishunfeng pushed a commit to branch dev
in repository https://gitbox.apache.org/repos/asf/dolphinscheduler.git


The following commit(s) were added to refs/heads/dev by this push:
     new 4a29c6a6c8 [Improvement-9338][API] show more create datasource exception message (#9336)
4a29c6a6c8 is described below

commit 4a29c6a6c8dffd3522c89a8ddd0139ef8bde5922
Author: zchong <zc...@163.com>
AuthorDate: Wed Apr 6 09:17:29 2022 +0800

    [Improvement-9338][API] show more create datasource exception message (#9336)
    
    * Update DataSourceServiceImpl.java
    
    fix  error message miss
    
    * Update DataSourceServiceImpl.java
    
    import optional jar
---
 .../dolphinscheduler/api/service/impl/DataSourceServiceImpl.java  | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/DataSourceServiceImpl.java b/dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/DataSourceServiceImpl.java
index b93abff45c..0ad634210a 100644
--- a/dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/DataSourceServiceImpl.java
+++ b/dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/DataSourceServiceImpl.java
@@ -50,6 +50,7 @@ import java.util.HashSet;
 import java.util.List;
 import java.util.Map;
 import java.util.Set;
+import java.util.Optional;
 
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
@@ -337,8 +338,11 @@ public class DataSourceServiceImpl extends BaseServiceImpl implements DataSource
             putMsg(result, Status.SUCCESS);
             return result;
         } catch (Exception e) {
-            logger.error("datasource test connection error, dbType:{}, connectionParam:{}, message:{}.", type, connectionParam, e.getMessage());
-            return new Result<>(Status.CONNECTION_TEST_FAILURE.getCode(), e.getMessage());
+            String message = Optional.of(e).map(Throwable::getCause)
+                    .map(Throwable::getMessage)
+                    .orElse(e.getMessage());
+            logger.error("datasource test connection error, dbType:{}, connectionParam:{}, message:{}.", type, connectionParam, message);
+            return new Result<>(Status.CONNECTION_TEST_FAILURE.getCode(), message);
         }
     }