Skip to content

Commit f30eb01

Browse files
updated return type
1 parent 0bfe3ad commit f30eb01

File tree

4 files changed

+9
-8
lines changed

4 files changed

+9
-8
lines changed

src/main/java/io/cdap/plugin/snowflake/common/SnowflakeErrorType.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
import io.cdap.cdap.api.exception.ErrorCodeType;
2121
import io.cdap.cdap.api.exception.ErrorType;
2222
import io.cdap.cdap.api.exception.ErrorUtils;
23+
import io.cdap.cdap.api.exception.ProgramFailureException;
2324
import io.cdap.plugin.snowflake.common.util.DocumentUrlUtil;
2425
import net.snowflake.client.jdbc.ErrorCode;
2526

@@ -168,7 +169,8 @@ private static ErrorCategory getErrorCategoryFromSqlState(int errorCode) {
168169
return new ErrorCategory(ErrorCategory.ErrorCategoryEnum.PLUGIN);
169170
}
170171

171-
public static void fetchProgramFailureException(SQLException e, String errorReason, String errorMessage) {
172+
public static ProgramFailureException fetchProgramFailureException(SQLException e, String errorReason,
173+
String errorMessage) {
172174
Optional<ErrorCode> errorCodes = Arrays.stream(ErrorCode.values())
173175
.filter(errorCode -> errorCode.getSqlState().equals(e.getSQLState()))
174176
.findFirst();
@@ -177,7 +179,7 @@ public static void fetchProgramFailureException(SQLException e, String errorReas
177179
new ErrorCategory(ErrorCategory.ErrorCategoryEnum.PLUGIN);
178180
ErrorType errorType = errorCodes.isPresent() ? getErrorTypeFromErrorCode(errorCodes.get().getMessageCode()) :
179181
ErrorType.UNKNOWN;
180-
throw ErrorUtils.getProgramFailureException(errorCategory, errorReason, errorMessage, errorType,
182+
return ErrorUtils.getProgramFailureException(errorCategory, errorReason, errorMessage, errorType,
181183
true, ErrorCodeType.SQLSTATE, e.getSQLState(), DocumentUrlUtil.getSupportedDocumentUrl(), e);
182184
}
183185
}

src/main/java/io/cdap/plugin/snowflake/common/client/SnowflakeAccessor.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ public void runSQL(String query) {
7070
query, e.getSQLState(), e.getErrorCode(), e.getMessage());
7171
String errorReason = String.format("Statement '%s' failed with SQL state %s and error code %s. For more " +
7272
"details see %s.", query, e.getSQLState(), e.getErrorCode(), DocumentUrlUtil.getSupportedDocumentUrl());
73-
SnowflakeErrorType.fetchProgramFailureException(e, errorReason, errorMessage);
73+
throw SnowflakeErrorType.fetchProgramFailureException(e, errorReason, errorMessage);
7474
}
7575
}
7676

@@ -100,7 +100,7 @@ public List<SnowflakeFieldDescriptor> describeQuery(String query) throws IOExcep
100100
"code %s with message: %s.", e.getSQLState(), e.getErrorCode(), e.getMessage());
101101
String errorReason = String.format("Failed to execute query to fetch descriptors with SQL State %s and error " +
102102
"code %s. For more details %s", e.getSQLState(), e.getErrorCode(), DocumentUrlUtil.getSupportedDocumentUrl());
103-
SnowflakeErrorType.fetchProgramFailureException(e, errorReason, errorMessage);
103+
throw SnowflakeErrorType.fetchProgramFailureException(e, errorReason, errorMessage);
104104
}
105105
return fieldDescriptors;
106106
}

src/main/java/io/cdap/plugin/snowflake/sink/batch/SnowflakeSinkAccessor.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ public void uploadStream(InputStream inputStream, String stageDir) {
6161
String errorMessage = String.format("Failed to compress '%s' and upload data to destination stage '%s' with " +
6262
"errorCode: '%s' and sqlState: '%s' with message: %s.", filename, stageDir, e.getErrorCode(), e.getSQLState(),
6363
e.getMessage());
64-
SnowflakeErrorType.fetchProgramFailureException(e, errorReason, errorMessage);
64+
throw SnowflakeErrorType.fetchProgramFailureException(e, errorReason, errorMessage);
6565
}
6666
}
6767

src/main/java/io/cdap/plugin/snowflake/source/batch/SnowflakeSourceAccessor.java

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ public List<String> prepareStageSplits() {
9898
DocumentUrlUtil.getSupportedDocumentUrl());
9999
String errorMessage = String.format("Failed to load data into stage '%s' with sqlState %s and errorCode %s. " +
100100
"Failed to execute query with message: %s.", STAGE_PATH, e.getSQLState(), e.getErrorCode(), e.getMessage());
101-
SnowflakeErrorType.fetchProgramFailureException(e, errorReason, errorMessage);
101+
throw SnowflakeErrorType.fetchProgramFailureException(e, errorReason, errorMessage);
102102
}
103103
return stageSplits;
104104
}
@@ -130,8 +130,7 @@ public CSVReader buildCsvReader(String stageSplit) {
130130
String errorMessage = String.format("Failed to execute the query with sqlState: '%s' & errorCode: '%s' " +
131131
"with message: %s, stage split at %s.", e.getSQLState(), e.getErrorCode(),
132132
e.getMessage(), stageSplit);
133-
SnowflakeErrorType.fetchProgramFailureException(e, errorReason, errorMessage);
133+
throw SnowflakeErrorType.fetchProgramFailureException(e, errorReason, errorMessage);
134134
}
135-
return null;
136135
}
137136
}

0 commit comments

Comments
 (0)