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

Method _handleError

lib/request-execution.js:284–320  ·  view source on GitHub ↗
(errorCode, err)

Source from the content-addressed store, hash-verified

282 }
283
284 _handleError(errorCode, err) {
285 this._parent.triedHosts[this._host.address] = err;
286 err['coordinator'] = this._host.address;
287
288 if (errorCode === errorCodes.serverErrorUnprepared) {
289 return this._prepareAndRetry(err.queryId);
290 }
291
292 if (errorCode === errorCodes.socketError || errorCode === errorCodes.socketErrorBeforeRequestWritten) {
293 this._host.removeFromPool(this._connection);
294 } else if (errorCode === errorCodes.clientTimeout) {
295 this._parent.log('warning', err.message);
296 this._host.checkHealth(this._connection);
297 }
298
299 const decisionInfo = this._getDecision(errorCode, err);
300
301 if (!decisionInfo || decisionInfo.decision === retry.RetryPolicy.retryDecision.rethrow) {
302 if (this._request instanceof requests.QueryRequest || this._request instanceof requests.ExecuteRequest) {
303 err['query'] = this._request.query;
304 }
305 return this._parent.setCompleted(err);
306 }
307
308 const metrics = this._parent.client.metrics;
309
310 if (decisionInfo.decision === retry.RetryPolicy.retryDecision.ignore) {
311 metrics.onIgnoreError(err);
312
313 // Return an empty ResultSet
314 return this._parent.setCompleted(null, this._getResultSet(utils.emptyObject));
315 }
316
317 RequestExecution._invokeMetricsHandlerForRetry(errorCode, metrics, err);
318
319 return this._retry(decisionInfo.consistency, decisionInfo.useCurrentHost);
320 }
321
322 /**
323 * Gets a decision whether or not to retry based on the error information.

Callers 2

restartMethod · 0.95
_sendOnConnectionMethod · 0.95

Calls 9

_prepareAndRetryMethod · 0.95
_getDecisionMethod · 0.95
_getResultSetMethod · 0.95
_retryMethod · 0.95
removeFromPoolMethod · 0.80
checkHealthMethod · 0.80
setCompletedMethod · 0.80
onIgnoreErrorMethod · 0.65

Tested by

no test coverage detected