Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(TCOMP-2710): improve workflow and exception throwing/handling #902

Merged
merged 9 commits into from
Aug 19, 2024
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
package org.talend.sdk.component.api.exception;

import javax.json.bind.annotation.JsonbCreator;
import javax.json.bind.annotation.JsonbPropertyOrder;

import lombok.Data;

Expand All @@ -28,13 +29,34 @@
* See me TCOMP-2342 for more details.
*/
@Data
@JsonbPropertyOrder({ "localizedMessage", "message", "stackTrace", "suppressed", "possibleHandleErrorWith" })
public class DiscoverSchemaException extends RuntimeException {

public enum HandleErrorWith {
/**
* default case
*/
EXCEPTION,
/**
* unhandled.
*/
SILENT,
/**
* unhandled.
*/
RETRY,
EXECUTE_MOCK_JOB;
/**
* Potentially execute a mock job in studio.
* Will ask user's validation before executing.
* When specifying this option, developer should be sure that no side effect can be generated by connector.
*/
EXECUTE_MOCK_JOB,
/**
* Will execute a lifecycle through framework using only configuration.
* This won't query for any user input.
* When specifying this option, developer should be sure that no side effect can be generated by connector.
*/
EXECUTE_LIFECYCLE;
}

private HandleErrorWith possibleHandleErrorWith = HandleErrorWith.EXCEPTION;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
import static java.util.Optional.ofNullable;
import static java.util.stream.Collectors.toList;
import static java.util.stream.Collectors.toMap;
import static org.talend.sdk.component.api.exception.DiscoverSchemaException.HandleErrorWith.EXECUTE_MOCK_JOB;
import static org.talend.sdk.component.api.exception.DiscoverSchemaException.HandleErrorWith.EXECUTE_LIFECYCLE;
import static org.talend.sdk.component.api.record.SchemaProperty.IS_KEY;
import static org.talend.sdk.component.api.record.SchemaProperty.PATTERN;
import static org.talend.sdk.component.api.record.SchemaProperty.SCALE;
Expand Down Expand Up @@ -202,13 +202,10 @@
try {
executeDiscoverSchemaExtendedAction(incomingSchema, outgoingBranch);
} catch (Exception e) {
// Case when a processor is the start of a studio job
if (isStartOfJob) {
final DiscoverSchemaException dse = transformException(e);
// When a processor is the start of a studio job and dev explicitly set the handleError to Lifecycle exec
if (isStartOfJob && EXECUTE_LIFECYCLE.equals(dse.getPossibleHandleErrorWith())) {

Check warning on line 207 in component-studio/component-runtime-di/src/main/java/org/talend/sdk/component/runtime/di/schema/TaCoKitGuessSchema.java

View check run for this annotation

sonar-eks / Component Runtime Sonarqube Results

component-studio/component-runtime-di/src/main/java/org/talend/sdk/component/runtime/di/schema/TaCoKitGuessSchema.java#L207

Use the primitive boolean expression here.
undx marked this conversation as resolved.
Show resolved Hide resolved
try {
final DiscoverSchemaException dse = transformException(e);
if (EXECUTE_MOCK_JOB.equals(dse.getPossibleHandleErrorWith())) {
throw handleException(dse);
}
guessOutputComponentSchemaThroughResult();
} catch (Exception er) {
throw handleException(e);
Expand Down
Loading
Loading