[Improvement-9338][API] show more create datasource exception message (#9336)
* Update DataSourceServiceImpl.java fix error message miss * Update DataSourceServiceImpl.java import optional jardependabot/maven/org.springframework-spring-core-5.3.18
parent
ee0e3beb9d
commit
4a29c6a6c8
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue