Skip to content

Commit 0cfa63a

Browse files
committed
Better error handling
1 parent 35cde0d commit 0cfa63a

File tree

2 files changed

+10
-1
lines changed

2 files changed

+10
-1
lines changed

src/main/java/com/coreyd97/stepper/sequence/StepSequence.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,9 @@ public void executeBlocking(){
8686
} catch (SequenceExecutionException e) {
8787
JOptionPane.showMessageDialog(Stepper.getUI().getUiComponent(), e.getMessage(),
8888
"Sequence Stopped", JOptionPane.ERROR_MESSAGE);
89+
}catch (Exception e){
90+
JOptionPane.showMessageDialog(Stepper.getUI().getUiComponent(), e.getMessage(),
91+
"Sequence Failed", JOptionPane.ERROR_MESSAGE);
8992
}
9093
for (SequenceExecutionListener stepLExecutionistener : sequenceExecutionListeners) {
9194
stepLExecutionistener.afterSequenceEnd(sequenceSuccess);

src/main/java/com/coreyd97/stepper/step/Step.java

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,13 @@ public StepExecutionInfo executeStep(List<StepVariable> replacements) throws Seq
150150

151151
long start = new Date().getTime();
152152
//Update with response
153-
IHttpRequestResponse requestResponse = Stepper.callbacks.makeHttpRequest(this.getHttpService(), builtRequest);
153+
IHttpRequestResponse requestResponse = null;
154+
try {
155+
requestResponse = Stepper.callbacks.makeHttpRequest(this.getHttpService(), builtRequest);
156+
}catch (RuntimeException e){
157+
if(e.getMessage().isEmpty() || e.getMessage().equalsIgnoreCase(this.hostname))
158+
throw new RuntimeException(String.format("Failed to execute step \"%s\"", this.title));
159+
}
154160
long end = new Date().getTime();
155161
if(requestResponse.getResponse() == null)
156162
throw new SequenceExecutionException("The request to the server timed out.");

0 commit comments

Comments
 (0)