Skip to content

Commit f2fba33

Browse files
committed
update runtime error
1 parent 5d4eb94 commit f2fba33

File tree

2 files changed

+11
-5
lines changed

2 files changed

+11
-5
lines changed

src/main/java/io/cdap/plugin/gcp/bigtable/source/BigtableSource.java

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,9 @@
2525
import io.cdap.cdap.api.data.format.StructuredRecord;
2626
import io.cdap.cdap.api.data.schema.Schema;
2727
import io.cdap.cdap.api.dataset.lib.KeyValue;
28+
import io.cdap.cdap.api.exception.ErrorCategory;
29+
import io.cdap.cdap.api.exception.ErrorType;
30+
import io.cdap.cdap.api.exception.ErrorUtils;
2831
import io.cdap.cdap.etl.api.Emitter;
2932
import io.cdap.cdap.etl.api.FailureCollector;
3033
import io.cdap.cdap.etl.api.PipelineConfigurer;
@@ -153,8 +156,9 @@ public void transform(KeyValue<ImmutableBytesWritable, Result> input, Emitter<St
153156
LOG.warn("Failed to process message, skipping it", e);
154157
break;
155158
case FAIL_PIPELINE:
156-
throw new RuntimeException("Failed to process message", e);
157-
// #TODO
159+
String error = String.format("Failed to process message: %s", e.getMessage());
160+
throw ErrorUtils.getProgramFailureException(new ErrorCategory(ErrorCategory.ErrorCategoryEnum.PLUGIN),
161+
error, error, ErrorType.UNKNOWN, false, e);
158162
default:
159163
// this should never happen because it is validated at configure and prepare time
160164
throw new IllegalStateException(String.format("Unknown error handling strategy '%s'",

src/main/java/io/cdap/plugin/gcp/common/GCPErrorDetailsProvider.java

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -61,20 +61,20 @@ public ProgramFailureException getExceptionDetails(Exception e, ErrorContext err
6161
return getProgramFailureException((IllegalStateException) t, errorContext);
6262
}
6363
if (t instanceof UnexpectedFormatException) {
64-
// TODO
64+
return getProgramFailureException((UnexpectedFormatException) t, errorContext);
6565
}
6666
}
6767
return null;
6868
}
6969

7070
/**
7171
* Get a ProgramFailureException with the given error
72-
* information from {@link IllegalArgumentException}.
72+
* information from {@link IllegalArgumentException}, {@link UnexpectedFormatException}.
7373
*
7474
* @param e The IllegalArgumentException to get the error information from.
7575
* @return A ProgramFailureException with the given error information.
7676
*/
77-
private ProgramFailureException getProgramFailureException(IllegalArgumentException e,
77+
private ProgramFailureException getProgramFailureException(Exception e,
7878
ErrorContext errorContext) {
7979
String errorMessage = e.getMessage();
8080
return ErrorUtils.getProgramFailureException(new ErrorCategory(ErrorCategoryEnum.PLUGIN),
@@ -97,6 +97,8 @@ private ProgramFailureException getProgramFailureException(IllegalStateException
9797
e.getClass().getName(), errorMessage), ErrorType.SYSTEM, false, e);
9898
}
9999

100+
101+
100102
/**
101103
* Get the external documentation link for the client errors if available.
102104
*

0 commit comments

Comments
 (0)