Create a MethodResult for an internal exception which occurred while trying to run a method

@param failure the internal exception
@return the new MethodResult
966406
public static <R> MethodResult<R> internalFailure(Throwable failure) {
        return new MethodResult<R>(null, failure, true);
    }
1000302
@Override
    public ApiResponse handleApplicationException(ApiFailureResource resource, RuntimeException cause) {
        final FaicliUnifiedFailureType failureType = FaicliUnifiedFailureType.BUSINESS_ERROR;
        final FaicliUnifiedFailureResult result = createFailureResult(failureType, resource, cause);
        return asJson(result).httpStatus(prepareBusinessFailureStatus());
    }
917494
private function failureException(MethodInvocation $invocation, FailureInterface $failure)
    {
        $class = new \ReflectionClass($invocation->getThis());
        $className = $class->implementsInterface(WeavedInterface::class) ? $class->getParentClass()->name : $class->name;
        $errors = json_encode($failure->getMessages());
        $msg = sprintf('%s::%s() %s', $className, $invocation->getMethod()->name, $errors);

        return new InvalidArgumentException($msg, 400);
    }
1063993
public static <U> CompletableFuture<U> failedFuture(Throwable ex) {
        if (ex == null) throw new NullPointerException();
        return new CompletableFuture<U>(new AltResult(ex));
    }
1319051
function failure(exception) {
		var message;
		message = proto.writeFailure(exception);
		notify(message);
		return that;
	}
1322432
public static Result failure(int code, String message) {
        return new Result(false, String.valueOf(code), message);
    }
505131
public static Result failure(int code, String message, List<Error> errors) {
        return new Result(code, message, errors);
    }
217811
boolean isFailure(ExecutionResult result) {
    return failureConditions.isEmpty() ?
        result.getFailure() != null :
        isFailure((R) result.getResult(), result.getFailure());
  }
287646
public static LdapException create(LdapResultCode resultCode, String message) {
        return new LdapException(resultCode, message, null);
    }
917987
public static <T> CompletableFuture<T> failedFuture(Throwable exception) {
        CompletableFuture<T> result = new CompletableFuture<>();
        result.completeExceptionally(exception);
        return result;
    }
1339953
public static <T extends Throwable, A> Try<T, A> success(A a) {
        return new Success<>(a);
    }
192589
public S handleIf(Predicate<? extends Throwable> failurePredicate) {
    Assert.notNull(failurePredicate, "failurePredicate");
    failuresChecked = true;
    failureConditions.add(failurePredicateFor(failurePredicate));
    return (S) this;
  }
470937
public static <T> IQueryResult<T> errorResult(Throwable exception) {
        return packageResult(null, CompletionStatus.ERROR,
            exception == null ? null : Collections.singletonMap("exception", (Object) exception));
    }
1160960
protected String createAndlogStackTrace(Failure failure) {
        StringBuilder sb = new StringBuilder();

        if (failure.getMessage() != null && !failure.getMessage().isEmpty()) {
            sb.append("Failure message: ").append(failure.getMessage());
        }

        if (failure.getException() != null) {
            sb.append("\n\n");
            sb.append(failure.getException().getClass().getCanonicalName()).append(": ").append(failure.getMessage()).append("\n");

            for (StackTraceElement ste : failure.getException().getStackTrace()) {
                sb.append("\tat ").append(ste.getClassName()).append(".").append(ste.getMethodName()).
                    append("(").append(ste.getFileName()).append(":").append(ste.getLineNumber()).append(")\n");

                if (!fullStackTraces && ste.getClassName().equals(failure.getDescription().getClassName())) {
                    sb.append("\t...\n");
                    break;
                }
            }

            if (fullStackTraces && failure.getException().getCause() != null) {
                sb.append("Cause: ").append(failure.getException().getCause().getMessage()).append("\n");

                for (StackTraceElement ste : failure.getException().getCause().getStackTrace()) {
                    sb.append("\tat ").append(ste.getClassName()).append(".").append(ste.getMethodName()).
                        append("(").append(ste.getFileName()).append(":").append(ste.getLineNumber()).append(")\n");
                }
            }

            LOGGER.info("\n" + failure.getTestHeader() + "\n" + sb.toString());
        }

        return sb.toString();
    }
555334
public static <T> Result<T> failed(String msg) {
        return Result.<T>builder().success(false).msg(msg).build();
    }
824886
private function getFailure(MethodInvocation $invocation, FailureInterface $failure, \ReflectionMethod $onFailure = null)
    {
        if ($onFailure) {
            return $onFailure->invoke($invocation->getThis(), $failure);
        }

        return $this->failureException($invocation, $failure);
    }
873929
public S handle(Class<? extends Throwable> failure) {
    Assert.notNull(failure, "failure");
    return handle(Arrays.asList(failure));
  }