Skip to content

Instantly share code, notes, and snippets.

@jsocol
Last active April 23, 2018 22:07
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jsocol/6aebadf0ef1065ca55382dbb796ffa38 to your computer and use it in GitHub Desktop.
Save jsocol/6aebadf0ef1065ca55382dbb796ffa38 to your computer and use it in GitHub Desktop.
finally example
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