Incorrect documentation for Internal Requests
- Dominant language
- PHP
- Stars
- 9.4k
- Forks
- 1.3k
- PR merge metrics
- No merged PRs in 30d
Description
According to the documentation, an InternalHttpException should be thrown when an error response (such as errorNotFound) is thrown during processing of an Internal Request; however, a Symphony\Component\HttpKernel\Exception\HttpException is thrown instead. This exception is more generic and lacks the getResponse() method shown in the docs.
From https://github.com/dingo/api/wiki/Internal-Requests:
> The package may also throw a Dingo\Api\Exception\InternalHttpException when an error response is returned. If you're using the response builder to return errors then you'll need to catch the thrown exception. The response will be available on the exception.
> public function show($id)
{
return $this->response->errorNotFound('Could not find the user.');
}
When internally calling this endpoint we'll need to catch the exception.
> try {
app('Dingo\Api\Dispatcher')->get('users/1');
} catch (Dingo\Api\Exception\InternalHttpException $e) {
// We can get the response here to check the status code of the error or response body.
$response = $e->getResponse();
}
Suspect line: https://github.com/dingo/api/blob/46cffad61942caa094dd876155e503b6819c5095/src/Http/Response/Factory.php#L173
Contributor guide
Assessment
This issue has not been assessed yet.