Class FlowInterruptedException
- java.lang.Object
-
- java.lang.Throwable
-
- java.lang.Exception
-
- java.lang.InterruptedException
-
- org.jenkinsci.plugins.workflow.steps.FlowInterruptedException
-
- All Implemented Interfaces:
Serializable
public final class FlowInterruptedException extends InterruptedException
Special exception that can be thrown out ofFutureCallback.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 findisActualInterruption()
useful in deciding whether to ignore or rethrow the exception.)No stack trace is printed (except by
Throwable.getCause()
and/orThrowable.getSuppressed()
if present), and you can control theResult
andCauseOfInterruption
.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 aCauseOfInterruption.UserInterruption
andResult.ABORTED
.- See Also:
- Serialized Form
-
-
Constructor Summary
Constructors Constructor Description FlowInterruptedException(Result result, boolean actualInterruption, CauseOfInterruption... causes)
Creates a new exception.FlowInterruptedException(Result result, CauseOfInterruption... causes)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description List<CauseOfInterruption>
getCauses()
Result
getResult()
void
handle(Run<?,?> run, TaskListener listener)
If a build catches this exception, it should use this method to report it.boolean
isActualInterruption()
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 Detail
-
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 Detail
-
getResult
@NonNull public Result getResult()
-
getCauses
@NonNull public List<CauseOfInterruption> getCauses()
-
isActualInterruption
public boolean isActualInterruption()
-
setActualInterruption
public void setActualInterruption(boolean actualInterruption)
-
handle
public void handle(Run<?,?> run, TaskListener listener)
If a build catches this exception, it should use this method to report it.
-
-