Skip to content

Commit 0249aec

Browse files
committed
Merge branch 'develop' into fem/postgresql
2 parents 6373949 + 0ef198a commit 0249aec

File tree

3 files changed

+25
-1
lines changed

3 files changed

+25
-1
lines changed

cloudsql-mysql-plugin/src/main/java/io/cdap/plugin/cloudsql/mysql/CloudSQLMySQLSource.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,11 @@ protected Class<? extends DBWritable> getDBRecordType() {
8181
return MysqlDBRecord.class;
8282
}
8383

84+
@Override
85+
protected String getExternalDocumentationLink() {
86+
return DBUtils.CLOUDSQLMYSQL_SUPPORTED_DOC_URL;
87+
}
88+
8489
@Override
8590
protected String createConnectionString() {
8691
if (CloudSQLUtil.PRIVATE_INSTANCE.equalsIgnoreCase(

database-commons/src/main/java/io/cdap/plugin/db/source/AbstractDBSource.java

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
import io.cdap.cdap.api.data.schema.Schema;
2727
import io.cdap.cdap.api.dataset.lib.KeyValue;
2828
import io.cdap.cdap.api.exception.ErrorCategory;
29+
import io.cdap.cdap.api.exception.ErrorCodeType;
2930
import io.cdap.cdap.api.exception.ErrorType;
3031
import io.cdap.cdap.api.exception.ErrorUtils;
3132
import io.cdap.cdap.api.plugin.PluginConfig;
@@ -202,8 +203,17 @@ private Schema loadSchemaFromDB(Class<? extends Driver> driverClass)
202203
// wrap exception to ensure SQLException-child instances not exposed to contexts without jdbc driver in classpath
203204
String errorMessageWithDetails = String.format("Error occurred while trying to get schema from database." +
204205
"Error message: '%s'. Error code: '%s'. SQLState: '%s'", e.getMessage(), e.getErrorCode(), e.getSQLState());
206+
String externalDocumentationLink = getExternalDocumentationLink();
207+
if (!Strings.isNullOrEmpty(externalDocumentationLink)) {
208+
if (!errorMessageWithDetails.endsWith(".")) {
209+
errorMessageWithDetails = errorMessageWithDetails + ".";
210+
}
211+
errorMessageWithDetails = String.format("%s For more details, see %s", errorMessageWithDetails,
212+
externalDocumentationLink);
213+
}
205214
throw ErrorUtils.getProgramFailureException(new ErrorCategory(ErrorCategory.ErrorCategoryEnum.PLUGIN),
206-
e.getMessage(), errorMessageWithDetails, ErrorType.USER, false, new SQLException(e.getMessage(),
215+
e.getMessage(), errorMessageWithDetails, ErrorType.USER, false, ErrorCodeType.SQLSTATE,
216+
e.getSQLState(), externalDocumentationLink, new SQLException(e.getMessage(),
207217
e.getSQLState(), e.getErrorCode()));
208218
} finally {
209219
driverCleanup.destroy();
@@ -363,6 +373,10 @@ protected Class<? extends DBWritable> getDBRecordType() {
363373
return DBRecord.class;
364374
}
365375

376+
protected String getExternalDocumentationLink() {
377+
return null;
378+
}
379+
366380
@Override
367381
public void initialize(BatchRuntimeContext context) throws Exception {
368382
super.initialize(context);

mysql-plugin/src/main/java/io/cdap/plugin/mysql/MysqlSource.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,11 @@ protected Class<? extends DBWritable> getDBRecordType() {
6969
return MysqlDBRecord.class;
7070
}
7171

72+
@Override
73+
protected String getExternalDocumentationLink() {
74+
return DBUtils.MYSQL_SUPPORTED_DOC_URL;
75+
}
76+
7277
@Override
7378
protected LineageRecorder getLineageRecorder(BatchSourceContext context) {
7479
String fqn = DBUtils.constructFQN("mysql",

0 commit comments

Comments
 (0)