Last active
August 29, 2015 14:00
-
-
Save maarten00/11168039 to your computer and use it in GitHub Desktop.
Laravel Exception Mailer
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<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> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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( '[email protected]', 'DTC Media Reporter' ); | |
$message->to( '[email protected]' )->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