Skip to content

Can not get exception in JSON format #57

@koroan

Description

@koroan

Bug Report

Q A
Version(s) 1.8.0

Summary

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?

Metadata

Metadata

Assignees

No one assigned

    Labels

    QuestionFurther information is requested

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions