Default behavior returns true if Throwable is included in RETRY_EXCEPTIONS
attribute (if declared).  If this attribute is not declared, any IOExceptions are
considered retryable.
163539
public boolean isRetryable(Throwable ex) {
        try {
            String retryableAttr = getAttributeValueSmart(PROP_RETRY_EXCEPTIONS);
            if (retryableAttr != null) {
                for (String retryableExClass : retryableAttr.split(",")) {
                    if (ex.getClass().getName().equals(retryableExClass)
                            || (ex.getCause() != null && ex.getCause().getClass().getName()
                                    .equals(retryableExClass)))
                        return true;
                }
                return false;
            }
        }
        catch (Exception e) {
            logger.severeException(e.getMessage(), e);
        }

        return ex instanceof IOException;
    }
994591
public static Throwable stripException(Throwable throwableToStrip, Class<? extends Throwable> typeToStrip) {
		while (typeToStrip.isAssignableFrom(throwableToStrip.getClass()) && throwableToStrip.getCause() != null) {
			throwableToStrip = throwableToStrip.getCause();
		}

		return throwableToStrip;
	}
992865
def threw(self, error_type=None):
        
        if not error_type:
            return True if len(self.exceptions) > 0 else False
        else:
            return uch.obj_in_list(self.exceptions, error_type)
121053
public boolean hasException(Class<? extends Throwable> type) {
        for (Throwable exception : exceptions) {
            if (type.isInstance(exception)) {
                return true;
            }
        }
        
        return false;
    }
1246678
def _should_retry(self, context):
        # type: (ExponentialRetryWithMaxWait,
        #        azure.storage.common.models.RetryContext) -> bool
        
        # do not retry if max attempts equal or exceeded
        if context.count >= self.max_attempts:
            return False

        # get response status
        status = None
        if context.response and context.response.status:
            status = context.response.status

        # if there is no response status, then handle the exception
        # appropriately from the lower layer
        if status is None:
            exc = context.exception
            # default to not retry in unknown/unhandled exception case
            ret = False
            # requests timeout, retry
            if isinstance(exc, requests.Timeout):
                ret = True
            elif isinstance(exc, requests.exceptions.ContentDecodingError):
                ret = True
            elif (isinstance(exc, requests.exceptions.ConnectionError) or
                  isinstance(exc, requests.exceptions.ChunkedEncodingError)):
                # newer versions of requests do not expose errno on the
                # args[0] reason object; manually string parse
                if isinstance(exc.args[0], urllib3.exceptions.MaxRetryError):
                    try:
                        msg = exc.args[0].reason.args[0]
                    except (AttributeError, IndexError):
                        # unexpected/malformed exception hierarchy, don't retry
                        pass
                    else:
                        if any(x in msg for x in _RETRYABLE_ERRNO_MAXRETRY):
                            ret = True
                elif isinstance(exc.args[0], urllib3.exceptions.ProtocolError):
                    try:
                        msg = exc.args[0].args[0]
                    except (AttributeError, IndexError):
                        # unexpected/malformed exception hierarchy, don't retry
                        pass
                    else:
                        if any(x in msg for x in _RETRYABLE_ERRNO_PROTOCOL):
                            ret = True
            # fallback to string search
            if not ret:
                msg = str(exc).lower()
                if any(x in msg for x in _RETRYABLE_STRING_FALLBACK):
                    ret = True
            return ret
        elif 200 <= status < 300:
            # failure during respond body download or parsing, so success
            # codes should be retried
            return True
        elif 300 <= status < 500:
            # response code 404 should be retried if secondary was used
            if (status == 404 and
                    context.location_mode ==
                    azure.storage.common.models.LocationMode.SECONDARY):
                return True
            # response code 408 is a timeout and should be retried
            # response code 429 is too many requests (throttle)
            # TODO use "Retry-After" header for backoff amount
            if status == 408 or status == 429:
                return True
            return False
        elif status >= 500:
            # response codes above 500 should be retried except for
            # 501 (not implemented) and 505 (version not supported)
            if status == 501 or status == 505:
                return False
            return True
        else:  # noqa
            # this should be unreachable, retry anyway
            return True
959245
public static <Return> Return retryUntilNoException(Callable<Return> callable, int maxTry, Class<? extends Throwable> exceptionClass) throws Exception {
        String errMsg = "连续重试失败" + maxTry + "次。";
        Exception t = null;
        while (maxTry > 0) {
            try {
                return callable.call();
            } catch (Exception throwable) {
                if (exceptionClass.isAssignableFrom(throwable.getClass())) {
                    //只对指定的异常重试，其他异常直接抛出去
                    maxTry--;
                    t = throwable;
                } else {
                    throw throwable;
                }
            }
        }
        LOG.error(new RuntimeException(errMsg, t));
        //这里是对重试N次后依然抛出指定异常的情况，原样抛出
        throw t;
    }
871284
protected Boolean getApplicationExceptionRollback(Throwable t) {
        Boolean rollback;
        if (ivIgnoreApplicationExceptions) {
            rollback = null;
        } else {
            ComponentMetaData cmd = getComponentMetaData();
            EJBModuleMetaDataImpl mmd = (EJBModuleMetaDataImpl) cmd.getModuleMetaData();
            rollback = mmd.getApplicationExceptionRollback(t);
        }
        return rollback;
    }
898867
public function isReportableException()
    {
        $handler = app(ExceptionHandler::class);

        return method_exists($handler, 'shouldReport')
                ? $handler->shouldReport($this->exception) : true;
    }
612759
boolean isIgnorable(Throwable throwable) {
        if (ignoreExceptions == null || ignoreExceptions.isEmpty()) {
            return false;
        }
        for (Class<? extends Throwable> ignoreException : ignoreExceptions) {
            if (ignoreException.isAssignableFrom(throwable.getClass())) {
                return true;
            }
        }
        return false;
    }
474606
private boolean handleException(final Throwable t,
                                  final HttpServletResponse resp,
                                  final boolean serverError) {
    if (serverError) {
      return true;
    }

    try {
      error(t);
      sendError(t, resp);
      return true;
    } catch (Throwable t1) {
      // Pretty much screwed if we get here
      return true;
    }
  }
659832
private boolean handleError(C4Error c4err) {
        // If this is a transient error, or if I'm continuous and the error might go away with a change
        // in network (i.e. network down, hostname unknown), then go offline and retry later.
        final boolean isTransient = C4Replicator.mayBeTransient(c4err) ||
            ((c4err.getDomain() == C4Constants.ErrorDomain.WEB_SOCKET) &&
                (c4err.getCode() == C4WebSocketCloseCode.kWebSocketCloseUserTransient));

        final boolean isNetworkDependent = C4Replicator.mayBeNetworkDependent(c4err);
        if (!isTransient && !(config.isContinuous() && isNetworkDependent)) {
            return false; // nope, this is permanent
        }
        if (!config.isContinuous() && retryCount >= MAX_ONE_SHOT_RETRY_COUNT) {
            return false; //too many retries
        }

        clearRepl();

        if (!isTransient) {
            Log.i(DOMAIN, "%s: Network error (%s); will retry when network changes...", this, c4err);
        }
        else {
            // On transient error, retry periodically, with exponential backoff:
            final int delay = retryDelay(++retryCount);
            Log.i(DOMAIN, "%s: Transient error (%s); will retry in %d sec...", this, c4err, delay);
            handler.schedule(
                new Runnable() {
                    @Override
                    public void run() {
                        retry();
                    }
                },
                delay,
                TimeUnit.SECONDS);
        }

        // Also retry when the network changes:
        startReachabilityObserver();
        return true;
    }
86977
public void processFailure(WriteBatch batch, Throwable throwable) {
    boolean isHostUnavailableException = processException(batch.getBatcher(), throwable, batch.getClient().getHost());
    if ( isHostUnavailableException == true ) {
      try {
        logger.warn("Retrying failed batch: {}, results so far: {}, uris: {}",
          batch.getJobBatchNumber(), batch.getJobWritesSoFar(),
          Stream.of(batch.getItems()).map(event->event.getTargetUri()).collect(Collectors.toList()));
        batch.getBatcher().retryWithFailureListeners(batch);
      } catch (RuntimeException e) {
        logger.error("Exception during retry", e);
        processFailure(batch, e);
      }
    }
  }
1182567
public static boolean isTransientError(Throwable throwable) {
        if (throwable instanceof CouchbaseLiteException) {
            CouchbaseLiteException e = (CouchbaseLiteException) throwable;
            return isTransientError(e.getCBLStatus().getCode());
        } else if (throwable instanceof RemoteRequestResponseException) {
            RemoteRequestResponseException e = (RemoteRequestResponseException) throwable;
            return isTransientError(e.getCode());
        } else if (throwable instanceof java.net.SocketTimeoutException)
            // connection and socket timeouts => transient error
            return true;
        else if (throwable instanceof java.net.ConnectException)
            return true;
        else if (throwable instanceof java.net.SocketException)
            return true;
        else if (throwable instanceof IOException)
            // NOTE: Exception is thrown from HttpClient.execute() or InputStream.read()
            //       As InputStream.read() thrown IOException, So IOException is considered
            //       temporary issue.
            return true;
        else
            return false;
    }
961555
public static final RetryPolicy retryByException(RetryPolicy defaultPolicy,
                                                   Map<Class<? extends Exception>, RetryPolicy> exceptionToPolicyMap) {
    return new ExceptionDependentRetry(defaultPolicy, exceptionToPolicyMap);
  }
229744
public boolean isFailure(R result, Throwable failure) {
    for (BiPredicate<R, Throwable> predicate : failureConditions) {
      try {
        if (predicate.test(result, failure))
          return true;
      } catch (Exception ignored) {
        // Ignore confused user-supplied predicates.
        // They should not be allowed to halt execution of the operation.
      }
    }

    // Fail by default if a failure is not checked by a condition
    return failure != null && !failuresChecked;
  }
934102
public void registerThrowable(RetryContext context, Throwable throwable) {
		RetryPolicy policy = (RetryPolicy) context;
		policy.registerThrowable(context, throwable);
		((RetryContextSupport) context).registerThrowable(throwable);
	}
1338490
@Override
	public boolean canRetry(RetryContext context) {
		Throwable t = context.getLastThrowable();
		return (t == null || retryForException(t))
				&& context.getRetryCount() < this.maxAttempts;
	}