123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110 |
- <?php namespace Laravel;
- class Error {
-
- public static function exception($exception, $trace = true)
- {
- static::log($exception);
- ob_get_level() and ob_end_clean();
-
-
-
- if (Config::get('error.detail'))
- {
- echo "<html><h2>Unhandled Exception</h2>
- <h3>Message:</h3>
- <pre>".$exception->getMessage()."</pre>
- <h3>Location:</h3>
- <pre>".$exception->getFile()." on line ".$exception->getLine()."</pre>";
- if ($trace)
- {
- echo "
- <h3>Stack Trace:</h3>
- <pre>".$exception->getTraceAsString()."</pre></html>";
- }
- }
-
-
-
- else
- {
- $response = Event::first('500');
- return Response::prepare($response)->send();
- }
- exit(1);
- }
-
- public static function native($code, $error, $file, $line)
- {
- if (error_reporting() === 0) return;
-
-
-
- $exception = new \ErrorException($error, $code, 0, $file, $line);
- if (in_array($code, Config::get('error.ignore')))
- {
- return static::log($exception);
- }
- static::exception($exception);
- }
-
- public static function shutdown()
- {
-
-
-
- $error = error_get_last();
- if ( ! is_null($error))
- {
- extract($error, EXTR_SKIP);
- static::exception(new \ErrorException($message, $type, 0, $file, $line), false);
- }
- }
-
- public static function log($exception)
- {
- if (Config::get('error.log'))
- {
- call_user_func(Config::get('error.logger'), $exception);
- }
- }
- }
|