Skip to content

Commit fb1b8f5

Browse files
committed
Wrap Upsert operation error
1 parent 84432d6 commit fb1b8f5

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

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

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,9 @@
2121
import io.cdap.cdap.api.common.Bytes;
2222
import io.cdap.cdap.api.data.format.StructuredRecord;
2323
import io.cdap.cdap.api.data.schema.Schema;
24+
import io.cdap.cdap.api.exception.ErrorCategory;
25+
import io.cdap.cdap.api.exception.ErrorType;
26+
import io.cdap.cdap.api.exception.ErrorUtils;
2427
import io.cdap.plugin.util.DBUtils;
2528
import io.cdap.plugin.util.Lazy;
2629
import org.apache.hadoop.conf.Configurable;
@@ -305,7 +308,10 @@ protected void updateOperation(PreparedStatement stmt) throws SQLException {
305308
* @throws SQLException
306309
*/
307310
protected void upsertOperation(PreparedStatement stmt) throws SQLException {
308-
throw new UnsupportedOperationException();
311+
String errorMessage = "Upsert operation is not supported for this plugin.";
312+
throw ErrorUtils.getProgramFailureException(new ErrorCategory(ErrorCategory.ErrorCategoryEnum.PLUGIN),
313+
errorMessage, errorMessage, ErrorType.SYSTEM, false, new UnsupportedOperationException(errorMessage));
314+
309315
}
310316

311317
private boolean fillUpdateParams(List<String> updatedKeyList, ColumnType columnType) {

0 commit comments

Comments
 (0)