From acdf89097b858ac89167594a790aad6b59a36fa2 Mon Sep 17 00:00:00 2001 From: Jan Hecking Date: Tue, 2 Oct 2018 12:01:49 +0800 Subject: [PATCH] Make use of new error.client getter --- README.md | 13 +++++++------ docs/overview.md | 13 +++++++------ 2 files changed, 14 insertions(+), 12 deletions(-) diff --git a/README.md b/README.md index 5b575be0..c1708691 100644 --- a/README.md +++ b/README.md @@ -71,7 +71,7 @@ Aerospike.connect(config) return client.operate(key, ops) }) .then(result => { - console.log(result.bins) // => { i: 124, l: 4, m: null } + console.log(result.bins) // => { i: 124, l: 4, m: null } return client.get(key) }) @@ -85,12 +85,13 @@ Aerospike.connect(config) // m: { foo: 4 } } }) .then(() => client.close()) - .catch(error => { - client.close() - return Promise.reject(error) - }) }) - .catch(error => console.log(error)) + .catch(error => { + console.error('Error: %s [%i]', error.message, error.code) + if (error.client) { + error.client.close() + } + }) ``` More examples illustrating the use of the API are located in the diff --git a/docs/overview.md b/docs/overview.md index 6933f3fb..c90f962c 100644 --- a/docs/overview.md +++ b/docs/overview.md @@ -118,7 +118,7 @@ Aerospike.connect(config) return client.operate(key, ops) }) .then(result => { - console.log(result.bins) // => { i: 124, l: 4, m: null } + console.log(result.bins) // => { i: 124, l: 4, m: null } return client.get(key) }) @@ -132,12 +132,13 @@ Aerospike.connect(config) // m: { foo: 4 } } }) .then(() => client.close()) - .catch(error => { - client.close() - return Promise.reject(error) - }) }) - .catch(error => console.log(error)) + .catch(error => { + console.error('Error: %s [%i]', error.message, error.code) + if (error.client) { + error.client.close() + } + }) ``` ## Tutorials