Skip to content

Instantly share code, notes, and snippets.

@maarten00
Last active August 29, 2015 14:00
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save maarten00/11168039 to your computer and use it in GitHub Desktop.
Save maarten00/11168039 to your computer and use it in GitHub Desktop.
Laravel Exception Mailer
<h1>Exception in {{ App::environment() }}-environment!</h1>
<strong>Code</strong>: {{ $exception->getCode() }}<br>
<strong>Exception message</strong>: {{ $exception->getMessage() }}<br>
<strong>Exception file</strong>: {{ $exception->getFile() }}<br>
<strong>Exception line</strong>: {{ $exception->getLine() }}<br>
<hr/>
<strong>INPUT vars:</strong><br>
<pre style="font-family: 'courier new', courier, typewriter, monospace;">
{{ print_r( $input, true ) }}
</pre>
<hr/>
<strong>SERVER vars:</strong><br>
<pre style="font-family: 'courier new', courier, typewriter, monospace;">
{{ print_r( $server, true ) }}
</pre>
<hr/>
<strong>Laravel Session vars:</strong><br>
<pre style="font-family: 'courier new', courier, typewriter, monospace;">
{{ print_r( $session, true ) }}
</pre>
App::error(function(Exception $exception, $code)
{
$log = Log::getMonolog();
$log->addDebug('Input: '. print_r(Input::all(), TRUE));
$log->addDebug('SERVER: '. print_r($_SERVER, TRUE));
$log->addDebug('Laravel Session: '. print_r(Session::all(), TRUE));
Log::error($exception);
if ( App::environment("live", "staging") ) {
Mail::send( 'emails.exception',
array( 'exception' => $exception, 'code' => $code, 'input' => Input::all(), 'server' => $_SERVER, 'session' => Session::all() ),
function ( $message ) {
$message->from( 'noreply@dtcmedia.nl', 'DTC Media Reporter' );
$message->to( 'onderhoud@dtcmedia.nl' )->subject( sprintf("[SAM Koppeling] [%s] Exception!", App::environment()) );
} );
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment