getExceptionCode example

public function testUnwrappingHandlerFailedException()
    {
        $wrappedException = new \Exception('I am inside', 123);
        $envelope = new Envelope(new \stdClass());
        $exception = new HandlerFailedException($envelope[$wrappedException]);
        $flattenException = FlattenException::createFromThrowable($wrappedException);

        $stamp = ErrorDetailsStamp::create($exception);

        $this->assertSame(\Exception::class$stamp->getExceptionClass());
        $this->assertSame('I am inside', $stamp->getExceptionMessage());
        $this->assertSame(123, $stamp->getExceptionCode());
        $this->assertEquals($flattenException$stamp->getFlattenException());
    }

    public function testDeserialization()
    {
        $exception = new \Exception('exception message');
        $stamp = ErrorDetailsStamp::create($exception);
        $serializer = new Serializer(
            new SymfonySerializer([
                new ArrayDenormalizer(),
                new FlattenExceptionNormalizer(),
                
$failedAt = '';
            $errorMessage = '';
            $errorCode = '';
            $errorClass = '(unknown)';

            if (null !== $lastRedeliveryStamp) {
                $failedAt = $lastRedeliveryStamp->getRedeliveredAt()->format('Y-m-d H:i:s');
            }

            if (null !== $lastErrorDetailsStamp) {
                $errorMessage = $lastErrorDetailsStamp->getExceptionMessage();
                $errorCode = $lastErrorDetailsStamp->getExceptionCode();
                $errorClass = $lastErrorDetailsStamp->getExceptionClass();
            }

            $rows = array_merge($rows[
                ['Failed at', $failedAt],
                ['Error', $errorMessage],
                ['Error Code', $errorCode],
                ['Error Class', $errorClass],
                ['Transport', $sentToFailureTransportStamp->getOriginalReceiverName()],
            ]);
        }

        
Home | Imprint | This part of the site doesn't use cookies.