Skip to content

Commit 291ebcd

Browse files
committed
Merge pull request jenkinsci#36 from patoi/try-catch-finally
better error handling
2 parents 5cde08a + 57ff4e7 commit 291ebcd

File tree

1 file changed

+2
-12
lines changed
  • jenkinsfile-examples/nodejs-build-test-deploy-docker-notify

1 file changed

+2
-12
lines changed

jenkinsfile-examples/nodejs-build-test-deploy-docker-notify/Jenkinsfile

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -74,9 +74,8 @@ node('node') {
7474
}
7575

7676

77-
catch (caughtError) {
77+
catch (err) {
7878

79-
err = caughtError
8079
currentBuild.result = "FAILURE"
8180

8281
mail body: "project build error: ${err}" ,
@@ -85,16 +84,7 @@ node('node') {
8584
subject: 'project build failed',
8685
8786

88-
}
89-
90-
finally {
91-
92-
93-
/* Must re-throw exception to propagate error */
94-
if (err) {
95-
throw err
96-
}
97-
87+
throw err
9888
}
9989

10090
}

0 commit comments

Comments
 (0)