Skip to content

Commit

Permalink
formatting and method names.
Browse files Browse the repository at this point in the history
  • Loading branch information
taylorotwell committed Aug 25, 2017
1 parent c6e5bdf commit 2db9716
Showing 1 changed file with 37 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -32,53 +32,70 @@ protected function withExceptionHandling()
}

/**
* Disable exception handling for the test.
* Only handle the given exceptions via the exception handler.
*
* @param array $exceptions
* @return $this
*/
protected function withoutExceptionHandling()
protected function handleExceptions(array $exceptions)
{
return $this->turnOffExceptionHandling();
return $this->withoutExceptionHandling($exceptions);
}

/**
* @param array $exceptions
* Only handle validation exceptions via the exception handler.
*
* @return $this
*/
protected function handleExceptions(array $exceptions)
{
return $this->turnOffExceptionHandling($exceptions);
}

protected function handleValidationException()
protected function handleValidationExceptions()
{
return $this->handleExceptions([ValidationException::class]);
}

/**
* Disable exception handling for the test.
*
* @param array $except
* @return $this
*/
protected function turnOffExceptionHandling(array $except = [])
protected function withoutExceptionHandling(array $except = [])
{
$this->previousExceptionHandler = app(ExceptionHandler::class);

$this->app->instance(ExceptionHandler::class, new class($this->previousExceptionHandler, $except) implements ExceptionHandler {
protected $except;
protected $previousHandler;

/**
* Create a new class instance.
*
* @param \Illuminate\Contracts\Debug\ExceptionHandler
* @param array $except
* @return void
*/
public function __construct($previousHandler, $except = [])
{
$this->previousHandler = $previousHandler;
$this->except = $except;
$this->previousHandler = $previousHandler;
}

/**
* Report the given exception.
*
* @param \Exception $e
* @return void
*/
public function report(Exception $e)
{
//
}

/**
* Render the given exception.
*
* @param \Illuminate\Http\Request $request
* @param \Exception $e
* @return mixed
*/
public function render($request, Exception $e)
{
if ($e instanceof NotFoundHttpException) {
Expand All @@ -96,6 +113,13 @@ public function render($request, Exception $e)
throw $e;
}

/**
* Render the exception for the console.
*
* @param \Symfony\Component\Console\Output\OutputInterface
* @param \Exception $e
* @return void
*/
public function renderForConsole($output, Exception $e)
{
(new ConsoleApplication)->renderException($e, $output);
Expand Down

1 comment on commit 2db9716

@sileence
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for adding this new feature. I was wondering if I should move the anonymous class to a new file or it doesn't really matter?

Please sign in to comment.