|  | @@ -0,0 +1,63 @@
 | 
	
		
			
				|  |  | +<?php namespace App\Infrastructure;
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +use Exception;
 | 
	
		
			
				|  |  | +use Psr\Log\LoggerInterface;
 | 
	
		
			
				|  |  | +use Symfony\Component\Debug\ExceptionHandler as SymfonyDisplayer;
 | 
	
		
			
				|  |  | +use Illuminate\Contracts\Debug\ExceptionHandler as ExceptionHandlerContract;
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +class ExceptionHandler implements ExceptionHandlerContract {
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +	/**
 | 
	
		
			
				|  |  | +	 * The log implementation.
 | 
	
		
			
				|  |  | +	 *
 | 
	
		
			
				|  |  | +	 * @var \Psr\Log\LoggerInterface
 | 
	
		
			
				|  |  | +	 */
 | 
	
		
			
				|  |  | +	protected $log;
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +	/**
 | 
	
		
			
				|  |  | +	 * Create a new exception handler instance.
 | 
	
		
			
				|  |  | +	 *
 | 
	
		
			
				|  |  | +	 * @param  \Psr\Log\LoggerInterface  $log
 | 
	
		
			
				|  |  | +	 * @return void
 | 
	
		
			
				|  |  | +	 */
 | 
	
		
			
				|  |  | +	public function __construct(LoggerInterface $log)
 | 
	
		
			
				|  |  | +	{
 | 
	
		
			
				|  |  | +		$this->log = $log;
 | 
	
		
			
				|  |  | +	}
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +	/**
 | 
	
		
			
				|  |  | +	 * Report or log an exception.
 | 
	
		
			
				|  |  | +	 *
 | 
	
		
			
				|  |  | +	 * @param  \Exception  $e
 | 
	
		
			
				|  |  | +	 * @return void
 | 
	
		
			
				|  |  | +	 */
 | 
	
		
			
				|  |  | +	public function report(Exception $e)
 | 
	
		
			
				|  |  | +	{
 | 
	
		
			
				|  |  | +		$this->log->error((string) $e);
 | 
	
		
			
				|  |  | +	}
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +	/**
 | 
	
		
			
				|  |  | +	 * Render an exception into a response.
 | 
	
		
			
				|  |  | +	 *
 | 
	
		
			
				|  |  | +	 * @param  \Illuminate\Http\Request  $request
 | 
	
		
			
				|  |  | +	 * @param  \Exception  $e
 | 
	
		
			
				|  |  | +	 * @return \Symfony\Component\HttpFoundation\Response
 | 
	
		
			
				|  |  | +	 */
 | 
	
		
			
				|  |  | +	public function render($request, Exception $e)
 | 
	
		
			
				|  |  | +	{
 | 
	
		
			
				|  |  | +		return (new SymfonyDisplayer)->createResponse($e);
 | 
	
		
			
				|  |  | +	}
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +	/**
 | 
	
		
			
				|  |  | +	 * Render an exception to the console.
 | 
	
		
			
				|  |  | +	 *
 | 
	
		
			
				|  |  | +	 * @param  \Symfony\Component\Console\Output\OutputInterface  $output
 | 
	
		
			
				|  |  | +	 * @param  \Exception  $e
 | 
	
		
			
				|  |  | +	 * @return void
 | 
	
		
			
				|  |  | +	 */
 | 
	
		
			
				|  |  | +	public function renderForConsole($output, Exception $e)
 | 
	
		
			
				|  |  | +	{
 | 
	
		
			
				|  |  | +		$output->writeln((string) $e);
 | 
	
		
			
				|  |  | +	}
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +}
 |