Skip to content

Instantly share code, notes, and snippets.

@jacoelho
Created April 13, 2017 12:28
Show Gist options
  • Save jacoelho/ffa06ba2b9f22e75d5398a7d97297541 to your computer and use it in GitHub Desktop.
Save jacoelho/ffa06ba2b9f22e75d5398a7d97297541 to your computer and use it in GitHub Desktop.
def timeoutWithMsg(Map args) {
try {
args.body()
} catch(err) {
String user = err.getCauses()[0]?.getUser()?.toString()
if (user == 'SYSTEM') {
args.timeout()
} else {
args.abort(user)
}
}
}
timeoutWithMsg(
body: { ->
//throw new IOException()
1 +2
},
timeout: { ->
println "timeout"
},
abort: { a ->
println "aborted ${a}"
}
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment