Skip to content

Commit

Permalink
improve error messages
Browse files Browse the repository at this point in the history
  • Loading branch information
cwensel committed Jun 24, 2023
1 parent 2532744 commit 62b6810
Showing 1 changed file with 28 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,11 @@

package io.clusterless.tessellate.pipeline;

import cascading.CascadingException;
import cascading.flow.Flow;
import cascading.flow.local.LocalFlowConnector;
import cascading.flow.local.LocalFlowProcess;
import cascading.flow.stream.duct.DuctException;
import cascading.operation.Debug;
import cascading.operation.Insert;
import cascading.operation.regex.RegexParser;
Expand Down Expand Up @@ -190,11 +192,36 @@ public Integer run() throws IOException {

running.set(true);
try {
flow.complete();
try {
flow.complete();
} catch (CascadingException e) {
return handleCascadingException(e);
}
} finally {
running.set(false);
}

return 0;
}

private Integer handleCascadingException(CascadingException cascadingException) {
Throwable cause = cascadingException.getCause();

if (cause instanceof DuctException) {
LOG.error("flow failed with: {}: {}", cause.getMessage(), cause.getCause().getMessage(), cascadingException);
System.err.println("flow failed with: " + cause.getMessage() + ": " + cause.getCause().getMessage());
return -1;
}

if (cause instanceof CascadingException) {
LOG.error("flow failed with: {}: {}", cause.getMessage(), cause.getCause().getMessage(), cascadingException);
System.err.println("flow failed with: " + cause.getMessage() + ": " + cause.getCause().getMessage());
return -1;
}

LOG.error("flow failed with: {}", cascadingException.getMessage(), cascadingException);
System.err.println("flow failed with: " + cause.getMessage());

return -1;
}
}

0 comments on commit 62b6810

Please sign in to comment.