Skip to content

Instantly share code, notes, and snippets.

@jsocol
Last active April 23, 2018 22:07
Show Gist options
  • Save jsocol/6aebadf0ef1065ca55382dbb796ffa38 to your computer and use it in GitHub Desktop.
Save jsocol/6aebadf0ef1065ca55382dbb796ffa38 to your computer and use it in GitHub Desktop.

Revisions

  1. jsocol revised this gist Apr 23, 2018. 1 changed file with 1 addition and 0 deletions.
    1 change: 1 addition & 0 deletions finally.js
    Original file line number Diff line number Diff line change
    @@ -6,6 +6,7 @@ async function batchFunctionFinally(commands) {
    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()
  2. jsocol created this gist Apr 23, 2018.
    14 changes: 14 additions & 0 deletions finally.js
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,14 @@
    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
    } 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));
    }