06.10.2016 Views

laravel-5

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

Errors & Logging 340<br />

1 /**<br />

2 * Report or log an exception.<br />

3 *<br />

4 * This is a great spot to send exceptions to Sentry, Bugsnag, etc.<br />

5 *<br />

6 * @param \Exception $e<br />

7 * @return void<br />

8 */<br />

9 public function report(Exception $e)<br />

10 {<br />

11 if ($e instanceof CustomException) {<br />

12 //<br />

13 }<br />

14<br />

15 return parent::report($e);<br />

16 }<br />

Ignoring Exceptions By Type<br />

The $dontReport property of the exception handler contains an array of exception types that will<br />

not be logged. By default, exceptions resulting from 404 errors are not written to your log files. You<br />

may add other exception types to this array as needed.<br />

The Render Method<br />

The render method is responsible for converting a given exception into an HTTP response that<br />

should be sent back to the browser. By default, the exception is passed to the base class which<br />

generates a response for you. However, you are free to check the exception type or return your own<br />

custom response:<br />

1 /**<br />

2 * Render an exception into an HTTP response.<br />

3 *<br />

4 * @param \Illuminate\Http\Request $request<br />

5 * @param \Exception $e<br />

6 * @return \Illuminate\Http\Response<br />

7 */<br />

8 public function render($request, Exception $e)<br />

9 {<br />

10 if ($e instanceof CustomException) {

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!