Skip to content

Commit

Permalink
Fixed error handler
Browse files Browse the repository at this point in the history
  • Loading branch information
AdrianSkierniewski committed Nov 8, 2015
1 parent df6f6b4 commit f4aa100
Showing 1 changed file with 8 additions and 7 deletions.
15 changes: 8 additions & 7 deletions app/Exceptions/Handler.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,33 +46,34 @@ public function report(Exception $e)
public function render($request, Exception $e)
{
if ($request->ajax()) {
$cors = app()->make('Asm89\Stack\CorsService');
/** @var $CORS \Asm89\Stack\CorsService */
$CORS = app()->make('Asm89\Stack\CorsService');
if ($e instanceof ValidationException) {
return $cors->addActualRequestHeaders(
return $CORS->addActualRequestHeaders(
response()->json(
[
'code' => self::VALIDATION_ERROR,
'error' => $e->getErrors()
],
500
self::VALIDATION_ERROR
),
$request
);
} else if (App::environment() == 'production') {
return $cors->addActualRequestHeaders(
return $CORS->addActualRequestHeaders(
response()->json(
[
'code' => self::SERVER_ERROR,
'error' => [
'message' => $e->getMessage(),
]
],
500
self::SERVER_ERROR
),
$request
);
} else {
return $cors->addActualRequestHeaders(
return $CORS->addActualRequestHeaders(
response()->json(
[
'code' => self::SERVER_ERROR,
Expand All @@ -83,7 +84,7 @@ public function render($request, Exception $e)
'line' => $e->getLine(),
]
],
500
self::SERVER_ERROR
),
$request
);
Expand Down

0 comments on commit f4aa100

Please sign in to comment.