{@inheritdoc}

@throws FailureException
327061
final public function beginTransaction(int $isolation = Transaction::ISOLATION_COMMITTED): Promise
    {
        if (! $this->handle) {
            throw new FailureException('Not connected');
        }

        return call(function () use ($isolation) {
            switch ($isolation) {
                case Transaction::ISOLATION_UNCOMMITTED:
                    yield $this->handle->query("BEGIN TRANSACTION ISOLATION LEVEL READ UNCOMMITTED");
                    break;

                case Transaction::ISOLATION_COMMITTED:
                    yield $this->handle->query("BEGIN TRANSACTION ISOLATION LEVEL READ COMMITTED");
                    break;

                case Transaction::ISOLATION_REPEATABLE:
                    yield $this->handle->query("BEGIN TRANSACTION ISOLATION LEVEL REPEATABLE READ");
                    break;

                case Transaction::ISOLATION_SERIALIZABLE:
                    yield $this->handle->query("BEGIN TRANSACTION ISOLATION LEVEL SERIALIZABLE");
                    break;

                default:
                    throw new \Error("Invalid transaction type");
            }

            $this->busy = new Deferred;

            return new ConnectionTransaction($this->handle, $this->callableFromInstanceMethod("release"), $isolation);
        });
    }
504208
public function failure(Exception $e, Delivery $delivery, AbstractListener $listener)
    {
        $listener->resend($delivery);
    }
344170
public function fail(\Exception $error = null, array $payload = []): void
    {
        $this->fire(new Event\SagaFailed($this, $payload, $error));
    }
443431
public void setFailures(java.util.Collection<Failure> failures) {
        if (failures == null) {
            this.failures = null;
            return;
        }

        this.failures = new com.amazonaws.internal.SdkInternalList<Failure>(failures);
    }
665161
protected function failedValidation(Validator $validator)
    {
        if ($this->container['request'] instanceof Request) {
            throw new ValidationException($validator, $this->getErrorCodes());
        }

        parent::failedValidation($validator);
    }
1249990
public function failed($e)
    {
        $this->markAsFailed();

        $payload = $this->payload();

        list($class, $method) = $this->parseJob($payload['job']);

        if (method_exists($this->instance = $this->resolve($class), 'failed')) {
            $this->instance->failed($payload['data'], $e);
        }
    }
836542
public function build(): FailRequestRequest
	{
		$instance = new FailRequestRequest();
		if ($this->requestId === null) {
			throw new BuilderException('Property [requestId] is required.');
		}
		$instance->requestId = $this->requestId;
		if ($this->errorReason === null) {
			throw new BuilderException('Property [errorReason] is required.');
		}
		$instance->errorReason = $this->errorReason;
		return $instance;
	}
1050592
protected function initializeValue($value)
    {
        if ($this->isEmpty($value) && ! $this->flags & Value::CAN_BE_EMPTY) {
            throw FailedToValidate::fromValueForClass($value, $this);
        }

        if (! $this->isEmpty($value)) {
            $value = $this->validate($value);
        }

        if (null === $value) {
            throw FailedToValidate::fromValueForClass($value, $this);
        }

        $this->value = $value;
    }
294521
@Override
    public void failed(Throwable x) {
        boolean failure = false;
        try (Locker.Lock lock = _locker.lock()) {
            switch (_state) {
                case SUCCEEDED:
                case FAILED:
                case IDLE:
                case CLOSED:
                case CALLED:
                    // too late!.
                    break;

                case PENDING:
                case PROCESSING: {
                    _state = State.FAILED;
                    failure = true;
                    break;
                }
                default:
                    throw new IllegalStateException(toString());
            }
        }
        if (failure)
            onCompleteFailure(x);
    }
240537
protected function fail($error = '')
    {
        $this->isFinished = true;
        $this->isSuccess = false;
        $this->error = $error;
    }
753245
public static function _failure($objects, $echoResponse = TRUE, $format = 'json') {
        return self::_doResponse('failure', $objects, $echoResponse, $format);
    }
824886
private function getFailure(MethodInvocation $invocation, FailureInterface $failure, \ReflectionMethod $onFailure = null)
    {
        if ($onFailure) {
            return $onFailure->invoke($invocation->getThis(), $failure);
        }

        return $this->failureException($invocation, $failure);
    }
579682
public void fail(String requestId) throws TException
    {
        int index = this.requestedMap.remove(requestId);
        DRPCInvocationsClient client = this.clients.get(index);
        client.failRequest(requestId);
    }
847883
protected function failIfContainerNotFound(ServiceException $exception, $action, $containerName)
    {
        $errorCode = $this->getErrorCodeFromServiceException($exception);

        if ($errorCode === self::ERROR_CONTAINER_NOT_FOUND) {
            throw new \RuntimeException(sprintf(
                'Failed to %s: container "%s" not found.',
                $action,
                $containerName
            ), $exception->getCode());
        }
    }
175397
protected function fail($errcode=-1, $errmsg=null, $data=null)
    {
        return static::error($errcode, $errmsg, $data);
    }
696256
protected function _fail( $message, $result = false)
    {
        // @todo Investigate the right function
        if ( $result !== false )
        {
            $message .= "\n" . pg_result_error( $result, PGSQL_DIAG_SQLSTATE ) . ": " . pg_result_error( $result, PGSQL_DIAG_MESSAGE_PRIMARY );
        }
        else
        {
            $errorInfo = $this->db->errorInfo();
            $message .= "\n$errorInfo[2]";
        }
        throw new Exception( $message );
    }
109400
private function fail()
    {
        $args = func_get_args();

        $format = array_shift($args);

        $regex = '/\{\{(?P<positive>[^{}]*)\|(?<negative>[^{}]*)\}\}/';
        preg_match_all($regex, $format, $matches);

        $replacements = $this->negative ? $matches['negative'] : $matches['positive'];

        foreach ($matches[0] as $i => $match) {
            $format = str_replace($match, $replacements[$i], $format);
        }

        $format = preg_replace('/\s+/', ' ', $format);

        foreach ($args as &$arg) {
            if (is_array($arg)) {
                $arg = 'Array';
                continue;
            }

            if (is_object($arg)) {
                $arg = 'Object of type "'.get_class($arg).'"';
                continue;
            }

            if ($arg === true) {
                $arg = 'TRUE';
                continue;
            }

            if ($arg === false) {
                $arg = 'FALSE';
                continue;
            }

            if ($arg === null) {
                $arg = 'NULL';
                continue;
            }

            if (is_string($arg)) {
                $arg = '"'.$arg.'"';
                continue;
            }
        }

        array_unshift($args, $format);
        $msg = (new ReflectionFunction('sprintf'))->invokeArgs($args);

        throw new AssertionFailureException($msg);
    }