MCPcopy Create free account
hub / github.com/apache/cassandra-nodejs-driver / setCompleted

Method setCompleted

lib/request-handler.js:241–277  ·  view source on GitHub ↗

* @param {Error} err * @param {ResultSet} [result]

(err, result)

Source from the content-addressed store, hash-verified

239 * @param {ResultSet} [result]
240 */
241 setCompleted(err, result) {
242 if (this._newExecutionTimeout !== null) {
243 clearTimeout(this._newExecutionTimeout);
244 }
245
246 // Mark all executions as cancelled
247 for (const execution of this._executions) {
248 execution.cancel();
249 }
250
251 if (err) {
252 if (this.executionOptions.getCaptureStackTrace()) {
253 utils.fixStack(this.stackContainer.stack, err);
254 }
255
256 // Reject the promise
257 return this._rejectCallback(err);
258 }
259
260 if (result.info.warnings) {
261 // Log the warnings from the response
262 result.info.warnings.forEach(function (message, i, warnings) {
263 this.log('warning', util.format(
264 'Received warning (%d of %d) "%s" for "%s"',
265 i + 1,
266 warnings.length,
267 message,
268 this.request.query || 'batch'));
269 }, this);
270 }
271
272 // We used to invoke the callback on next tick to allow stack unwinding and prevent the optimizing compiler to
273 // optimize read and write functions together.
274 // As we are resolving a Promise then() and catch() are always scheduled in the microtask queue
275 // We can invoke the resolve method directly.
276 this._resolveCallback(result);
277 }
278
279 /**
280 * @param {NoHostAvailableError} err

Callers 4

handleNoHostAvailableMethod · 0.95
_sendOnConnectionMethod · 0.80
_handleErrorMethod · 0.80
_prepareAndRetryMethod · 0.80

Calls 3

getCaptureStackTraceMethod · 0.65
forEachMethod · 0.65
cancelMethod · 0.45

Tested by

no test coverage detected