Skip to content

Commit

Permalink
Adds previous exception to the exception constructor's signatures
Browse files Browse the repository at this point in the history
  • Loading branch information
artstorm committed Jul 7, 2015
1 parent b041156 commit 1385fe8
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 6 deletions.
7 changes: 5 additions & 2 deletions api/app/Exceptions/BadRequestException.php
@@ -1,5 +1,6 @@
<?php namespace App\Exceptions;

use Exception;
use Symfony\Component\HttpKernel\Exception\HttpException;

class BadRequestException extends HttpException
Expand All @@ -8,10 +9,12 @@ class BadRequestException extends HttpException
* Create a new Bad Request exception instance.
*
* @param string $message
* @param int $code
* @param \Exception $previous
* @return void
*/
public function __construct($message = 'Bad Request.')
public function __construct($message = 'Bad Request.', $code = 0, Exception $previous = null)
{
parent::__construct(400, $message);
parent::__construct(400, $message, $previous);
}
}
7 changes: 5 additions & 2 deletions api/app/Exceptions/UnauthorizedException.php
@@ -1,5 +1,6 @@
<?php namespace App\Exceptions;

use Exception;
use Symfony\Component\HttpKernel\Exception\HttpException;

class UnauthorizedException extends HttpException
Expand All @@ -8,10 +9,12 @@ class UnauthorizedException extends HttpException
* Create a new Unauthorized exception instance.
*
* @param string $message
* @param int $code
* @param \Exception $previous
* @return void
*/
public function __construct($message = 'Unauthorized.')
public function __construct($message = 'Unauthorized.', $code = 0, Exception $previous = null)
{
parent::__construct(401, $message);
parent::__construct(401, $message, $previous);
}
}
3 changes: 2 additions & 1 deletion api/app/Exceptions/UnprocessableEntityException.php
Expand Up @@ -9,10 +9,11 @@ class UnprocessableEntityException extends HttpException
* Create a new Unprocessable Entity exception instance.
*
* @param string $message
* @param int $code
* @param \Exception $previous
* @return void
*/
public function __construct($message = 'Unprocessable Entity.', Exception $previous = null)
public function __construct($message = 'Unprocessable Entity.', $code = 0, Exception $previous = null)
{
parent::__construct(422, $message, $previous);
}
Expand Down
2 changes: 1 addition & 1 deletion api/app/Http/Controllers/AuthController.php
Expand Up @@ -72,7 +72,7 @@ public function refresh(Request $request)
$user = $this->jwtAuth->authenticate((string) $token);
}
catch (TokenExpiredException $e) {
throw new UnauthorizedException('Token expired.');
throw new UnauthorizedException('Token expired.', 401, $e);
}
catch (JWTException $e) {
throw new UnprocessableEntityException($e->getMessage(), $e);
Expand Down

0 comments on commit 1385fe8

Please sign in to comment.