github.com/jaylevin/jenkins-library@v1.230.4/documentation/docs/steps/handlePipelineStepErrors.md (about) 1 # ${docGenStepName} 2 3 ## ${docGenDescription} 4 5 ## Prerequisites 6 7 none 8 9 ## ${docGenParameters} 10 11 ## ${docGenConfiguration} 12 13 ## ${docJenkinsPluginDependencies} 14 15 ## Example 16 17 ```groovy 18 handlePipelineStepErrors (stepName: 'executeHealthCheck', stepParameters: parameters) { 19 // The code you want to get controlled by the error handler goes right here into the closure 20 def url = new Utils().getMandatoryParameter(parameters, 'url', null) 21 def statusCode = curl(url) 22 if (statusCode != '200') 23 error "Health Check failed: \${statusCode}" 24 } 25 ``` 26 27 ## Example console output 28 29 If `echoDetails` is set to true the following information will be output to the console: 30 31 1. Step beginning: `--- Begin library step: \${stepName}.groovy ---` 32 1. Step end: `--- End library step: \${stepName}.groovy ---` 33 1. Step errors: 34 35 ```log 36 ---------------------------------------------------------- 37 --- An error occurred in the library step: \${stepName} 38 ---------------------------------------------------------- 39 The following parameters were available to the step: 40 *** 41 \${stepParameters} 42 *** 43 The error was: 44 *** 45 \${err} 46 *** 47 Further information: 48 * Documentation of step \${stepName}: .../\${stepName}/ 49 * Pipeline documentation: https://... 50 * GitHub repository for pipeline steps: https://... 51 ---------------------------------------------------------- 52 ```