Created
April 13, 2017 12:28
-
-
Save jacoelho/ffa06ba2b9f22e75d5398a7d97297541 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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