Skip to content

Commit

Permalink
Fixing forbidden exceptions using incorrectly $errorBag
Browse files Browse the repository at this point in the history
  • Loading branch information
nilportugues committed Jul 4, 2016
1 parent e6f4077 commit 13fcbcf
Show file tree
Hide file tree
Showing 5 changed files with 7 additions and 8 deletions.
2 changes: 1 addition & 1 deletion src/Server/Actions/CreateResource.php
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ protected function getErrorResponse(Exception $e, ErrorBag $errorBag)
{
switch (get_class($e)) {
case ForbiddenException::class:
$response = $this->forbidden($errorBag);
$response = $this->forbidden($this->errorBag);
break;
case DataException::class:
$response = $this->unprocessableEntity($errorBag);
Expand Down
7 changes: 3 additions & 4 deletions src/Server/Actions/DeleteResource.php
Original file line number Diff line number Diff line change
Expand Up @@ -66,22 +66,21 @@ public function get($id, $className, callable $findOneCallable, callable $delete

return $this->resourceDeleted();
} catch (Exception $e) {
return $this->getErrorResponse($e, $this->errorBag);
return $this->getErrorResponse($e);
}
}

/**
* @param Exception $e
* @param ErrorBag $errorBag
*
* @return \Symfony\Component\HttpFoundation\Response
*/
protected function getErrorResponse(Exception $e, ErrorBag $errorBag)
protected function getErrorResponse(Exception $e)
{
switch (get_class($e)) {
case ForbiddenException::class:
$response = $this->forbidden(
new ErrorBag([new Error($e->getTitle(), $e->getMessage())])
new ErrorBag([new Error('Forbidden', $e->getMessage())])
);
break;
default:
Expand Down
2 changes: 1 addition & 1 deletion src/Server/Actions/GetResource.php
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ protected function getErrorResponse(Exception $e)
{
switch (get_class($e)) {
case ForbiddenException::class:
$response = $this->forbidden($errorBag);
$response = $this->forbidden($this->errorBag);
break;
case QueryException::class:
$response = $this->errorResponse($this->errorBag);
Expand Down
2 changes: 1 addition & 1 deletion src/Server/Actions/PatchResource.php
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ protected function getErrorResponse(Exception $e)
{
switch (get_class($e)) {
case ForbiddenException::class:
$response = $this->forbidden($errorBag);
$response = $this->forbidden($this->errorBag);
break;
case DataException::class:
$response = $this->unprocessableEntity($this->errorBag);
Expand Down
2 changes: 1 addition & 1 deletion src/Server/Actions/PutResource.php
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ protected function getErrorResponse(Exception $e)
{
switch (get_class($e)) {
case ForbiddenException::class:
$response = $this->forbidden($errorBag);
$response = $this->forbidden($this->errorBag);
break;
case DataException::class:
$response = $this->unprocessableEntity($this->errorBag);
Expand Down

0 comments on commit 13fcbcf

Please sign in to comment.