InternalHttpException Thrown with Validation on Internal Requests in 2.0.0-alpha2
- Dominant language
- PHP
- Stars
- 9.4k
- Forks
- 1.3k
- PR merge metrics
- No merged PRs in 30d
Description
| Q | A
| ----------------- | ---
| Bug? | yes
| New Feature? | no
| Framework | Laravel
| Framework version | 5.6.*
| Package version | 2.0.0-alpha2
| PHP version | 7.2.1
#### Actual Behaviour
Given the following controller method:
```
public function store(Request $request, $location_id)
{
$validator = Validator::make($request->all(), [
'name' => 'required|max:191',
]);
if ($validator->fails()) {
throw new StoreResourceFailedException('Could not create contact record.', $validator->errors());
}
// Continue with the rest of this method...
}
```
The method will work just fine if consuming the API by itself, but for _internal requests_, it will always throw an `InternalHttpException` for failed validation instead of `StoreResourceFailedException`.
#### Expected Behaviour
We should be able to specify the exception to be thrown, but it currently only throws `InternalHttpException` for internal requests.
#### Steps to Reproduce
Copy and paste the method above into a controller and try to make an internal request to it.
#### Possible Solutions
This feature seemed to work fine in version `2.0.0-alpha1`, but no longer works in `2.0.0-alpha2`. So maybe revert something back to the way it used to be...
Contributor guide
Assessment
This issue has not been assessed yet.