Determines if the cause of a story failure is {@link RestartingStoryFailure}
@param cause the {@link Throwable} containing the {@link RestartingStoryFailure} in its stack trace
@return true if found, false otherwise
513102
private boolean restartStory(Throwable cause) {
		while (cause != null) {
			if (cause instanceof RestartingStoryFailure) {
				return true;
			}
			cause = cause.getCause();
		}
		return false;
	}
891612
public static SessionException fromThrowable(Throwable cause) {
    return (cause instanceof SessionException)
                   ? (SessionException) cause
                   : new SessionException(cause);
  }
982504
public boolean setException(TBase<?, ?> result, Throwable cause) {
        final Class<?> causeType = cause.getClass();
        for (Entry<Class<Throwable>, TFieldIdEnum> e : exceptionFields.entrySet()) {
            if (e.getKey().isAssignableFrom(causeType)) {
                ThriftFieldAccess.set(result, e.getValue(), cause);
                return true;
            }
        }
        return false;
    }
44664
public RuntimeException traceError( RuntimeException cause ) {
        getLogger().log( Level.SEVERE, "Error during deserialization", cause );
        if ( wrapExceptions ) {
            return new JsonDeserializationException( cause );
        } else {
            return cause;
        }
    }
1260276
@Override
	public void onTaskFailure(Execution taskExecution, Throwable cause) {

		executionGraph.getJobMasterMainThreadExecutor().assertRunningInMainThread();

		// to better handle the lack of resources (potentially by a scale-in), we
		// make failures due to missing resources global failures 
		if (cause instanceof NoResourceAvailableException) {
			LOG.info("Not enough resources to schedule {} - triggering full recovery.", taskExecution);
			executionGraph.failGlobal(cause);
			return;
		}

		LOG.info("Recovering task failure for {} (#{}) via individual restart.", 
				taskExecution.getVertex().getTaskNameWithSubtaskIndex(), taskExecution.getAttemptNumber());

		numTaskFailures.inc();

		// trigger the restart once the task has reached its terminal state
		// Note: currently all tasks passed here are already in their terminal state,
		//       so we could actually avoid the future. We use it anyways because it is cheap and
		//       it helps to support better testing
		final CompletableFuture<ExecutionState> terminationFuture = taskExecution.getTerminalStateFuture();
		terminationFuture.thenRun(
			() -> performExecutionVertexRestart(taskExecution.getVertex(), taskExecution.getGlobalModVersion()));
	}
766114
public static boolean causedBy( final Throwable                     ex,
                                    final Class<? extends Throwable>    exceptionClass )
    {
        Throwable    cause = ex;

        while( cause != null && ! exceptionClass.isInstance( cause ) )
        {
            cause = cause.getCause();
        }

        return ( cause == null ) ? false : true;
    }
770055
public static DeleteException fromThrowable(Throwable cause) {
    return (cause instanceof DeleteException)
                   ? (DeleteException) cause
                   : new DeleteException(cause);
  }
195847
public void setFailure(Throwable cause) {
        if (this.isCancelled()) {
            this.releaseIfNeed(result);
            return;
        }
        if (setFailure0(cause)) {
            notifyListeners();
            return;
        }
        throw new IllegalStateException("complete already: " + this, cause);
    }
207283
protected static String getStackTrace(final Throwable cause) {
    if (cause == null) {
      return null;
    } else {
      final StringWriter writer = new StringWriter();
      cause.printStackTrace(new PrintWriter(writer));
      return writer.toString();
    }
  }
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;
    }
745774
public void requestFailed (Exception cause)
    {
        Object[] args = _args != null ? ArrayUtil.append(_args, cause) : new Object[] { cause };
        if (_slogger != null) {
            _slogger.warning(_errorText, args);
        } else if (_jlogger != null) {
            _jlogger.log(Level.WARNING, Logger.format(_errorText, args), cause);
        } else {
            System.err.println(Logger.format(_errorText, args));
        }
    }
790537
public static KbRuntimeException fromThrowable(Throwable cause) {
    return (cause instanceof KbRuntimeException)
                   ? (KbRuntimeException) cause
                   : new KbRuntimeException(cause);
  }
693359
protected void reportFailure (Exception cause)
    {
        for (int ii = 0, ll = _listeners.size(); ii < ll; ii++) {
            ClientResolutionListener crl = _listeners.get(ii);
            try {
                crl.resolutionFailed(_username, cause);
            } catch (Exception e) {
                log.warning("Client resolution listener choked in resolutionFailed()", "crl", crl,
                            "username", _username, "cause", cause, e);
            }
        }
    }
538140
public void onFailure (Throwable cause)
    {
        Console.log("Callback failure", "for", _trigger, cause);
        setEnabled(true);
        reportFailure(cause);
    }
122491
public boolean causeInstanceOf(Class<? extends Throwable> clazz) {
		Throwable cause = this.getCause();
		if (null != cause && clazz.isInstance(cause)) {
			return true;
		}
		return false;
	}
21141
public void requestFailed (Exception cause)
    {
        _error = cause;
        ResultListener<T> list = _list;
        _list = null;

        list.requestFailed(cause);
    }
1104624
private final static boolean hasBeenLogged(Throwable t) {
        boolean hasBeenLogged = false;
        Throwable cause = t;
        Throwable lastCause = null;
        while (cause != null && cause != lastCause) {
            if (cause instanceof RecursiveInjectionException) {
                if (((RecursiveInjectionException) cause).ivLogged) {
                    hasBeenLogged = true;
                } else {
                    // if we have not logged this recursive exception, make sure that it is only logged once
                    ((RecursiveInjectionException) cause).ivLogged = true;
                    hasBeenLogged = false;
                }
                break;
            }
            lastCause = cause;
            cause = cause.getCause();
        }

        return hasBeenLogged;
    }