Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Show nicer message when a job cannot be scheduled

  • Loading branch information...
commit 392e1c7ac8ef212c81a30634b983865e368eeffc 1 parent e91753f
@hithwen hithwen authored
View
19 src/main/java/com/cloudbees/plugins/flow/CouldNotScheduleJobException.java
@@ -0,0 +1,19 @@
+/*
+ * To change this template, choose Tools | Templates
+ * and open the template in the editor.
+ */
+package com.cloudbees.plugins.flow;
+
+/**
+ *
+ * @author Julia S.Simon <julia@tuenti.com>
+ */
+class CouldNotScheduleJobException extends RuntimeException {
+ public CouldNotScheduleJobException(Exception e) {
+ super(e);
+ }
+
+ public CouldNotScheduleJobException(String message, Exception e) {
+ super(message, e);
+ }
+}
View
11 src/main/java/com/cloudbees/plugins/flow/FlowRun.java
@@ -65,8 +65,15 @@ public FlowRun(BuildFlow job) throws IOException {
}
/* package */ Run schedule(JobInvocation job, List<Action> actions) throws ExecutionException, InterruptedException {
- job.run(new FlowCause(this),actions);
- addBuild(job.getBuild());
+
+ try {
+ job.run(new FlowCause(this),actions);
+ addBuild(job.getBuild());
+ } catch (Exception e) {
+
+ throw new CouldNotScheduleJobException("Could not schedule job"
+ + job.getProject().getName() +", ensure its not already enqueued with same parameters", e);
+ }
job.waitForCompletion();
getState().setResult(job.getResult());
return job.getBuild();
Please sign in to comment.
Something went wrong with that request. Please try again.