0

I want create a JSON Exception with Symfny in a controller. I can create a HTML exception with

 try {
     // code here
 } catch (InvalidArgumentException $e) {
       throw $this->createNotFoundException($e->getMessage());
 }

But it returns an HTML exception.

I try:

throw $this->createNotFoundException($e->getMessage())->setHeaders(['Content-Type'=>'application/json']);

But don't works

2

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.