Fosrestbundle: Exceptions thrown during exception serialization.

Created on 9 Dec 2017  路  7Comments  路  Source: FriendsOfSymfony/FOSRestBundle

I have two projects:


    • symfony 3.3.9



      • jms/serializer 1.8.1


      • jms/serializer-bundle 2.1.0


      • friendsofsymfony/rest-bundle 2.2.0




    • symfony 4.0.1



      • jms/serializer 1.10.0


      • jms/serializer-bundle 2.3.1


      • friendsofsymfony/rest-bundle 2.3.0



Example controller:

/**
  * @Route("/test")
  */
public function index()
{
    throw new \DomainException('an exception');
}

In the first project I get a proper response: {"code":500,"message":"an exception"}
However in the second one an exception is thrown:

(2/2)聽RuntimeExceptionResources are not supported in serialized data. Path: Symfony\Component\HttpKernel\Log\Logger -> Symfony\Component\HttpKernel\Debug\TraceableEventDispatcher -> ContainerOJzRqJn\srcDevDebugProjectContainer -> App\Auth\Controller\AuthController -> DomainException
--
in聽GraphNavigator.php聽(line 161)

I think in the first project FOS Rest Bundle used some kind of fallback when JMS could not serialize the exception (just my assumption). How to get the second project working properly?

Most helpful comment

Tests just don't pass yet as there are some more issues with the current implementation and I didn't find the time to finish it yet.

All 7 comments

This should be solved by https://github.com/FriendsOfSymfony/FOSRestBundle/pull/1805 (at least it works now on my side) @kbkk maybe you can test that commit so that @xabbuh can get the PR merged

Here the Composer Version Constraint:
"friendsofsymfony/rest-bundle": "dev-master#dcd5add5153af7e479e97a233efa6fdcd0164879 as 2.3",

@juliusstoerrle it did the trick. Why isn't it merged yet?

@kbkk Not sure, maybe @xabbuh wanted more feedback?

Tests just don't pass yet as there are some more issues with the current implementation and I didn't find the time to finish it yet.

Thanks for providing that issue! I also experienced the same. Fixed by switching to the dev version in composer.json:

"friendsofsymfony/rest-bundle": "2.3.x-dev"

So imho the issue here can be closed as the issue is merged allready into master branch.

Was this page helpful?
0 / 5 - 0 ratings