Last active
April 23, 2018 22:07
-
-
Save jsocol/6aebadf0ef1065ca55382dbb796ffa38 to your computer and use it in GitHub Desktop.
finally example
This file contains hidden or 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
async function batchFunctionFinally(commands) { | |
const batchStats = this.startBatch(commands) | |
let error = null | |
let response = null | |
try { | |
response = await this.redis.multi(commands) | |
} catch (e) { | |
error = e | |
throw e | |
} finally { | |
this.endBatch(batchStats, error, response) // if this throws, the rest of the finally block will be skipped | |
this.logStats() | |
} | |
return response.map(([error, data]) => error || data)); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment