Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
Amit-CloudSufi committed Feb 11, 2025
1 parent 1ca3c0f commit 0293f11
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 27 deletions.
12 changes: 8 additions & 4 deletions wrangler-transform/src/main/java/io/cdap/wrangler/Wrangler.java
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,9 @@
import io.cdap.cdap.api.annotation.Plugin;
import io.cdap.cdap.api.data.format.StructuredRecord;
import io.cdap.cdap.api.data.schema.Schema;
import io.cdap.cdap.api.exception.ErrorCategory;
import io.cdap.cdap.api.exception.ErrorType;
import io.cdap.cdap.api.exception.ErrorUtils;
import io.cdap.cdap.api.metrics.Metrics;
import io.cdap.cdap.api.plugin.PluginConfig;
import io.cdap.cdap.api.plugin.PluginProperties;
Expand Down Expand Up @@ -468,8 +470,9 @@ && checkPreconditionNotEmpty(false)) {
&& onErrorStrategy.equalsIgnoreCase(ON_ERROR_FAIL_PIPELINE)) {
String errorReason = String.format("Errors in Wrangler Transformation - %s",
errorMessages);
throw WranglerErrorUtil.getProgramFailureExceptionDetailsFromChain(null, errorReason,
errorReason, ErrorType.UNKNOWN);
throw ErrorUtils.getProgramFailureException(
new ErrorCategory(ErrorCategory.ErrorCategoryEnum.PLUGIN), errorReason, errorReason,
ErrorType.UNKNOWN, false, null);
}
}
} catch (Exception e) {
Expand Down Expand Up @@ -620,8 +623,9 @@ && checkPreconditionNotEmpty(true)) {

if (!Feature.WRANGLER_PRECONDITION_SQL.isEnabled(relationalTranformContext)) {
String errorReason = "SQL Precondition feature is not available";
throw WranglerErrorUtil.getProgramFailureExceptionDetailsFromChain(null, errorReason,
errorReason, ErrorType.SYSTEM);
throw ErrorUtils.getProgramFailureException(
new ErrorCategory(ErrorCategory.ErrorCategoryEnum.PLUGIN), errorReason, errorReason,
ErrorType.SYSTEM, false, null);
}

Optional<ExpressionFactory<String>> expressionFactory = getExpressionFactory(relationalTranformContext);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,35 +75,30 @@ private WranglerErrorUtil() {
*/
public static ProgramFailureException getProgramFailureExceptionDetailsFromChain(Throwable e,
String errorReason, String errorMessage, ErrorType errorType) {
if (e != null) {
List<Throwable> causalChain = Throwables.getCausalChain(e);
Throwable nonTerminalException = null;
for (Throwable t : causalChain) {
if (t instanceof ProgramFailureException) {
return null; // Avoid multiple wrap
}
if (NON_TERMINAL_EXCEPTIONS.containsKey(t.getClass().getName())) {
nonTerminalException = t; // Store non-terminal exception as fallback
continue;
}
String errorSubCategory = TERMINAL_EXCEPTIONS.get(t.getClass().getName());
if (errorSubCategory != null) {
return getProgramFailureException(t, errorReason, errorSubCategory);
}
List<Throwable> causalChain = Throwables.getCausalChain(e);
Throwable nonTerminalException = null;
for (Throwable t : causalChain) {
if (t instanceof ProgramFailureException) {
return null; // Avoid multiple wrap
}

if (nonTerminalException != null) {
return getProgramFailureException(nonTerminalException, errorReason,
NON_TERMINAL_EXCEPTIONS.get(nonTerminalException.getClass().getName()));
if (NON_TERMINAL_EXCEPTIONS.containsKey(t.getClass().getName())) {
nonTerminalException = t; // Store non-terminal exception as fallback
continue;
}
String errorSubCategory = TERMINAL_EXCEPTIONS.get(t.getClass().getName());
if (errorSubCategory != null) {
return getProgramFailureException(t, errorReason, errorSubCategory);
}
}

return ErrorUtils.getProgramFailureException(
new ErrorCategory(ErrorCategory.ErrorCategoryEnum.PLUGIN), errorReason, errorMessage,
errorType, false, e);
if (nonTerminalException != null) {
return getProgramFailureException(nonTerminalException, errorReason,
NON_TERMINAL_EXCEPTIONS.get(nonTerminalException.getClass().getName()));
}

return ErrorUtils.getProgramFailureException(
new ErrorCategory(ErrorCategory.ErrorCategoryEnum.PLUGIN), errorReason, errorMessage,
errorType, false, null);
errorType, false, e);
}

/**
Expand Down

0 comments on commit 0293f11

Please sign in to comment.