Skip to content

Commit

Permalink
Merge pull request #107 from SRLabs-Forks/3.2
Browse files Browse the repository at this point in the history
Update Exceptionhandler to match laravel/framework 5.2 Exception Handler
  • Loading branch information
crynobone committed Jan 21, 2016
2 parents 2d609a2 + 72ef50c commit ac9082b
Show file tree
Hide file tree
Showing 4 changed files with 70 additions and 2 deletions.
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
},
"require": {
"php": ">=5.5.0",
"laravel/framework": "~5.2.0",
"laravel/framework": "~5.2.7",
"orchestra/database": "~3.2.0",
"fzaninotto/faker": "~1.4",
"symfony/css-selector": "2.8.*|3.0.*",
Expand Down
18 changes: 18 additions & 0 deletions src/ApplictionTestCase.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<?php namespace Orchestra\Testbench;

use Orchestra\Testbench\Contracts\TestCase as TestCaseContract;

class ApplicationTestCase extends TestCase implements TestCaseContract
{
/**
* Resolve application HTTP exception handler.
*
* @param \Illuminate\Foundation\Application $app
*
* @return void
*/
protected function resolveApplicationExceptionHandler($app)
{
$app->singleton('Illuminate\Contracts\Debug\ExceptionHandler', 'Orchestra\Testbench\Exceptions\ApplicationHandler');
}
}
50 changes: 50 additions & 0 deletions src/Exceptions/ApplicationHandler.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
<?php namespace Orchestra\Testbench\Exceptions;

use Exception;
use Illuminate\Foundation\Testing\HttpException;
use Illuminate\Auth\Access\AuthorizationException;
use Illuminate\Validation\ValidationException;
use Illuminate\Database\Eloquent\ModelNotFoundException;
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
use Illuminate\Foundation\Exceptions\Handler as ExceptionHandler;

class ApplicationHandler extends ExceptionHandler
{
/**
* A list of the exception types that should not be reported.
*
* @var array
*/
protected $dontReport = [
AuthorizationException::class,
HttpException::class,
ModelNotFoundException::class,
ValidationException::class,
];

/**
* Report or log an exception.
*
* This is a great spot to send exceptions to Sentry, Bugsnag, etc.
*
* @param \Exception $e
* @return void
*/
public function report(Exception $e)
{
parent::report($e);
}

/**
* Render an exception into an HTTP response.
*
* @param \Illuminate\Http\Request $request
* @param \Exception $e
* @return \Illuminate\Http\Response
*/
public function render($request, Exception $e)
{
return parent::render($request, $e);
}
}

2 changes: 1 addition & 1 deletion src/Exceptions/Handler.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,4 @@ public function render($request, Exception $e)
{
throw $e;
}
}
}

0 comments on commit ac9082b

Please sign in to comment.