Skip to content

Commit

Permalink
Pass through the previous exception object
Browse files Browse the repository at this point in the history
  • Loading branch information
artstorm committed Jul 7, 2015
1 parent 2bc3421 commit 3cbdbf9
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
6 changes: 4 additions & 2 deletions api/app/Exceptions/UnprocessableEntityException.php
@@ -1,5 +1,6 @@
<?php namespace App\Exceptions;

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

class UnprocessableEntityException extends HttpException
Expand All @@ -8,10 +9,11 @@ class UnprocessableEntityException extends HttpException
* Create a new Unprocessable Entity exception instance.
*
* @param string $message
* @param \Exception $previous
* @return void
*/
public function __construct($message = 'Unprocessable Entity.')
public function __construct($message = 'Unprocessable Entity.', Exception $previous = null)
{
parent::__construct(422, $message);
parent::__construct(422, $message, $previous);
}
}
4 changes: 2 additions & 2 deletions api/app/Http/Controllers/AuthController.php
Expand Up @@ -50,7 +50,7 @@ public function login(Request $request)
throw new UnauthorizedException('Credentials failed.');
}
} catch (JWTException $e) {
throw new RuntimeException($e->getMessage());
throw new RuntimeException($e->getMessage(), 500, $e);
}

return $this->item(new AuthToken(['token' => $token]));
Expand All @@ -75,7 +75,7 @@ public function refresh(Request $request)
throw new UnauthorizedException('Token expired.');
}
catch (JWTException $e) {
throw new UnprocessableEntityException($e->getMessage());
throw new UnprocessableEntityException($e->getMessage(), $e);
}

if (!$user) {
Expand Down

0 comments on commit 3cbdbf9

Please sign in to comment.