Skip to content

Commit

Permalink
[ZEPPELIN-5780] Unify paragraph errors (apache#4422)
Browse files Browse the repository at this point in the history
  • Loading branch information
Reamer authored Jul 25, 2022
1 parent 0ab56cd commit 56312cb
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 28 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1073,7 +1073,6 @@ public InterpreterSetting getDefaultInterpreterSetting() {
}
}

@VisibleForTesting
public List<String> getSettingIds() {
List<String> settingIds = new ArrayList<>();
for (InterpreterSetting interpreterSetting : get()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -772,14 +772,12 @@ private void runAllSync(AuthenticationInfo authInfo, boolean isolated, Map<Strin
return;
}
} catch (InterpreterNotFoundException e) {
// ignore, because the following run method will fail if interpreter not found.
p.setInterpreterNotFound(e);
} finally {
// reset params to the original value
p.settings.setParams(originalParams);
}
}
} catch (Exception e) {
throw e;
} finally {
if (isolated) {
LOGGER.info("Releasing interpreters used by this note: {}", id);
Expand Down Expand Up @@ -1178,7 +1176,6 @@ public int hashCode() {
return result;
}

@VisibleForTesting
public static Gson getGSON() {
return GSON;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ public Date deserialize(JsonElement jsonElement, Type typeOF,
try {
return new SimpleDateFormat(format, Locale.US).parse(jsonElement.getAsString());
} catch (ParseException e) {
// try the next format
}
}
throw new JsonParseException("Unparsable date: \"" + jsonElement.getAsString()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -245,7 +245,6 @@ public Interpreter getBindedInterpreter() throws InterpreterNotFoundException {
return this.note.getInterpreterFactory().getInterpreter(intpText, executionContext);
}

@VisibleForTesting
public void setInterpreter(Interpreter interpreter) {
this.interpreter = interpreter;
}
Expand Down Expand Up @@ -375,18 +374,10 @@ public boolean execute(String interpreterGroupId, boolean blocking) {
return true;
}
} catch (InterpreterNotFoundException e) {
InterpreterResult intpResult =
new InterpreterResult(InterpreterResult.Code.ERROR,
String.format("Interpreter %s not found", this.intpText));
setReturn(intpResult, e);
setStatus(Job.Status.ERROR);
setInterpreterNotFound(e);
return false;
} catch (Throwable e) {
InterpreterResult intpResult =
new InterpreterResult(InterpreterResult.Code.ERROR,
"Unexpected exception: " + ExceptionUtils.getStackTrace(e));
setReturn(intpResult, e);
setStatus(Job.Status.ERROR);
setUnexpectedException(e);
return false;
}
}
Expand Down Expand Up @@ -463,7 +454,7 @@ protected InterpreterResult jobRun() throws Throwable {
settings.clear();
}

LOGGER.debug("RUN : " + script);
LOGGER.debug("RUN : {}", script);
try {
InterpreterContext context = getInterpreterContext();
InterpreterContext.set(context);
Expand Down Expand Up @@ -711,7 +702,7 @@ public void cleanOutputBuffer() {
* note you can see the latest checkpoint's output.
*/
public void checkpointOutput() {
LOGGER.info("Checkpoint Paragraph output for paragraph: " + getId());
LOGGER.info("Checkpoint Paragraph output for paragraph: {}", getId());
this.results = new InterpreterResult(Code.SUCCESS);
for (InterpreterResultMessage buffer : outputBuffer) {
results.add(buffer);
Expand Down Expand Up @@ -846,17 +837,25 @@ public void recover() {
}

} catch (InterpreterNotFoundException e) {
InterpreterResult intpResult =
new InterpreterResult(InterpreterResult.Code.ERROR,
String.format("Interpreter %s not found", this.intpText));
setReturn(intpResult, e);
setStatus(Job.Status.ERROR);
setInterpreterNotFound(e);
} catch (Throwable e) {
InterpreterResult intpResult =
new InterpreterResult(InterpreterResult.Code.ERROR,
"Unexpected exception: " + ExceptionUtils.getStackTrace(e));
setReturn(intpResult, e);
setStatus(Job.Status.ERROR);
setUnexpectedException(e);
}
}

public void setInterpreterNotFound(InterpreterNotFoundException e) {
InterpreterResult intpResult =
new InterpreterResult(InterpreterResult.Code.ERROR,
String.format("Interpreter %s not found", this.intpText));
setReturn(intpResult, e);
setStatus(Job.Status.ERROR);
}

public void setUnexpectedException(Throwable e) {
InterpreterResult intpResult =
new InterpreterResult(InterpreterResult.Code.ERROR,
"Unexpected exception: " + ExceptionUtils.getStackTrace(e));
setReturn(intpResult, e);
setStatus(Job.Status.ERROR);
}
}

0 comments on commit 56312cb

Please sign in to comment.