public function receivedException($type = null): ?EventCollection
    {
        $cardinality = $this->cardinality;

        if ($type instanceof InstanceHandle) {
            $type = $type->get();
        }

        if ($type instanceof Throwable) {
            $type = $this->matcherFactory->equalTo($type, true);
        } elseif ($this->matcherFactory->isMatcher($type)) {
            $type = $this->matcherFactory->adapt($type);
        }

        if ($result = $this->checkReceivedException($type)) {
            return $result;
        }

        return $this->assertionRecorder->createFailure(
            $this->assertionRenderer->renderGeneratorReceivedException(
                $this->subject,
                $cardinality,
                $type
            )
        );
    }