-
Type:
Bug
-
Resolution: Fixed
-
Priority:
Major
-
Component/s: pipeline
CpsStepContext.replay wraps checked exceptions in UndeclaredThrowableException; it has to, because the call from DSL implements GroovyObject.invokeMethod which, mysteriously, does not allow checked exceptions. After a few false starts, in https://github.com/jenkinsci/workflow-plugin/commit/2432b1e7518a2963983e9a099ae16b9ebfe1ffc1 I have made CpsBodyExecution.FailureAdapter unwrap this, so that this hack is transparent to ErrorAction (needed to handle AbortException in WorkflowRun.finish) and BodyExecutionCallback.onFailure (needed for CatchErrorStep, similarly to print a polite message not a stack trace).
Yet I have found that this wrapping is still not transparent: when a checked exception is thrown from a step (for example, an IOException from readFile), any Groovy code which tries to catch (IOException x) will not work; at the Groovy level, an UndeclaredThrowableException is received.