* Gets a decision whether or not to retry based on the error information. * @param {Number} errorCode * @param {Error} err * @returns {{decision, useCurrentHost, consistency}}
(errorCode, err)
| 326 | * @returns {{decision, useCurrentHost, consistency}} |
| 327 | */ |
| 328 | _getDecision(errorCode, err) { |
| 329 | const operationInfo = { |
| 330 | query: this._request && this._request.query, |
| 331 | executionOptions: this._parent.executionOptions, |
| 332 | nbRetry: this._retryCount |
| 333 | }; |
| 334 | |
| 335 | const retryPolicy = operationInfo.executionOptions.getRetryPolicy(); |
| 336 | |
| 337 | switch (errorCode) { |
| 338 | case errorCodes.socketErrorBeforeRequestWritten: |
| 339 | // The request was definitely not applied, it's safe to retry. |
| 340 | // Retry on the current host as there might be other connections open, in case it fails to obtain a connection |
| 341 | // on the current host, the driver will immediately retry on the next host. |
| 342 | return retryOnCurrentHost; |
| 343 | case errorCodes.socketError: |
| 344 | case errorCodes.clientTimeout: |
| 345 | case errorCodes.serverErrorOverloaded: |
| 346 | if (operationInfo.executionOptions.isIdempotent()) { |
| 347 | return retryPolicy.onRequestError(operationInfo, this._request.consistency, err); |
| 348 | } |
| 349 | return rethrowDecision; |
| 350 | case errorCodes.serverErrorUnavailable: |
| 351 | return retryPolicy.onUnavailable(operationInfo, err.consistencies, err.required, err.alive); |
| 352 | case errorCodes.serverErrorReadTimeout: |
| 353 | return retryPolicy.onReadTimeout( |
| 354 | operationInfo, err.consistencies, err.received, err.blockFor, err.isDataPresent); |
| 355 | case errorCodes.serverErrorWriteTimeout: |
| 356 | if (operationInfo.executionOptions.isIdempotent()) { |
| 357 | return retryPolicy.onWriteTimeout( |
| 358 | operationInfo, err.consistencies, err.received, err.blockFor, err.writeType); |
| 359 | } |
| 360 | return rethrowDecision; |
| 361 | default: |
| 362 | return rethrowDecision; |
| 363 | } |
| 364 | } |
| 365 | |
| 366 | static _getErrorCode(err) { |
| 367 | if (!err) { |
no test coverage detected