You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I want to throw exception inside Rpc controller, like this:
$ex = new \Laminas\ApiTools\ApiProblem\Exception\DomainException('The request you made was malformed', 400);
$ex->setType('/documentation/problems/malformed-request');
$ex->setTitle('Malformed Request');
$ex->setAdditionalDetails([
'missing-sort-direction' => 'The sort direction query string was missing and is required'
]);
throw $ex;
And I got an exception in html format (/module/Application/view/error/index.phtml works), but I was expecting response in JSON, like this:
HTTP/1.1 500 Internal Error
Content-Type: application/problem+json
{
"type": "/documentation/problems/malformed-request",
"detail": "The request you made was malformed",
"status": 400,
"title": "Malformed Request",
"missing-sort-direction": "The sort direction query string was missing and is required"
}
Of course I have header Content-Type: application/json
What I do incorrect? How can I get exception in Json format?
The text was updated successfully, but these errors were encountered:
Second, have you tried returning an ApiProblemResponse from your controller instead of throwing the exception? The documentation I linked demonstrates that, and it's an alternative to throwing the exception.
Bug Report
Summary
I want to throw exception inside Rpc controller, like this:
And I got an exception in html format (/module/Application/view/error/index.phtml works), but I was expecting response in JSON, like this:
Of course I have header Content-Type: application/json
What I do incorrect? How can I get exception in Json format?
The text was updated successfully, but these errors were encountered: