Class FlowInterruptedException
java.lang.Object
java.lang.Throwable
java.lang.Exception
java.lang.InterruptedException
org.jenkinsci.plugins.workflow.steps.FlowInterruptedException
- All Implemented Interfaces:
Serializable
Special exception that can be thrown out of
FutureCallback.onFailure(java.lang.Throwable)
to indicate that the flow was aborted from the inside.
(This could be caught like any other exception and rethrown or ignored. It only takes effect if thrown all the way up.
Consumers, such as steps, may find isActualInterruption()
useful in deciding whether to ignore or rethrow the exception.)
No stack trace is printed (except by Throwable.getCause()
and/or Throwable.getSuppressed()
if present),
and you can control the Result
and CauseOfInterruption
.
Analogous to Executor.interrupt(Result, CauseOfInterruption...)
but does not assume we are running inside an executor thread.
There is no need to call this from StepExecution.stop(java.lang.Throwable)
since in that case the execution owner
should have set a CauseOfInterruption.UserInterruption
and Result.ABORTED
.
- See Also:
-
Constructor Summary
ConstructorDescriptionFlowInterruptedException
(Result result, boolean actualInterruption, CauseOfInterruption... causes) Creates a new exception.FlowInterruptedException
(Result result, CauseOfInterruption... causes) Deprecated. -
Method Summary
Modifier and TypeMethodDescriptionvoid
handle
(Run<?, ?> run, TaskListener listener) If a build catches this exception, it should use this method to report it.boolean
void
setActualInterruption
(boolean actualInterruption) Methods inherited from class java.lang.Throwable
addSuppressed, fillInStackTrace, getCause, getLocalizedMessage, getMessage, getStackTrace, getSuppressed, initCause, printStackTrace, printStackTrace, printStackTrace, setStackTrace, toString
-
Constructor Details
-
FlowInterruptedException
@Deprecated public FlowInterruptedException(@NonNull Result result, @NonNull CauseOfInterruption... causes) -
FlowInterruptedException
public FlowInterruptedException(@NonNull Result result, boolean actualInterruption, @NonNull CauseOfInterruption... causes) Creates a new exception.- Parameters:
result
- the desired result for the flow, typicallyResult.ABORTED
causes
- any indicationsactualInterruption
- true if this is an actual build interruption (e.g. the user wants to abort the build)
-
-
Method Details
-
getResult
-
getCauses
-
isActualInterruption
public boolean isActualInterruption() -
setActualInterruption
public void setActualInterruption(boolean actualInterruption) -
handle
If a build catches this exception, it should use this method to report it.
-
FlowInterruptedException(Result, boolean, CauseOfInterruption...)