Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
S
syncEnrollments
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Yeray Santana Hualde
syncEnrollments
Commits
beb44eb4
Commit
beb44eb4
authored
Nov 16, 2011
by
Taylor Otwell
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #157 from sparksp/develop/exception
Refactor error handling to log ignored errors
parents
d3f93919
1d5fbab5
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
32 additions
and
18 deletions
+32
-18
laravel.php
laravel/laravel.php
+32
-18
No files found.
laravel/laravel.php
View file @
beb44eb4
...
@@ -15,22 +15,29 @@ require 'bootstrap/core.php';
...
@@ -15,22 +15,29 @@ require 'bootstrap/core.php';
date_default_timezone_set
(
Config
::
$items
[
'application'
][
'timezone'
]);
date_default_timezone_set
(
Config
::
$items
[
'application'
][
'timezone'
]);
/**
/**
* Create the exception handler function. All of the error handlers
* Create the exception logging function. All of the error logging
* registered by the framework call this closure to avoid duplicate
* is routed through here to avoid duplicate code. This Closure
* code. This Closure will determine if the logging Closure should
* will determine if the actual logging Closure should be called.
* be called, and will pass the exception to the developer defined
* handler in the configuration file.
*/
*/
$
handl
er
=
function
(
$exception
)
$
logg
er
=
function
(
$exception
)
{
{
$config
=
Config
::
$items
[
'error'
];
if
(
Config
::
$items
[
'error'
][
'log'
])
if
(
$config
[
'log'
])
{
{
call_user_func
(
$config
[
'logger'
],
$exception
);
call_user_func
(
Config
::
$items
[
'error'
]
[
'logger'
],
$exception
);
}
}
};
/**
* Create the exception handler function. All of the error handlers
* registered by the framework call this closure to avoid duplicate
* code. This Closure will pass the exception to the developer
* defined handler in the configuration file.
*/
$handler
=
function
(
$exception
)
use
(
$logger
)
{
$logger
(
$exception
);
if
(
$config
[
'detail'
])
if
(
Config
::
$items
[
'error'
]
[
'detail'
])
{
{
echo
"<html><h2>Unhandled Exception</h2>
echo
"<html><h2>Unhandled Exception</h2>
<h3>Message:</h3>
<h3>Message:</h3>
...
@@ -55,22 +62,29 @@ $handler = function($exception)
...
@@ -55,22 +62,29 @@ $handler = function($exception)
*/
*/
set_exception_handler
(
function
(
$exception
)
use
(
$handler
)
set_exception_handler
(
function
(
$exception
)
use
(
$handler
)
{
{
$handler
(
$exception
);
$handler
(
$exception
);
});
});
/**
/**
* Register the PHP error handler. All PHP errors will fall into this
* Register the PHP error handler. All PHP errors will fall into this
* handler, which will convert the error into an ErrorException object
* handler, which will convert the error into an ErrorException object
* and pass the exception into the common exception handler.
* and pass the exception into the common exception handler. Suppressed
* errors are ignored and errors in the developer configured whitelist
* are silently logged.
*/
*/
set_error_handler
(
function
(
$number
,
$error
,
$file
,
$line
)
set_error_handler
(
function
(
$number
,
$error
,
$file
,
$line
)
use
(
$logger
)
{
{
if
(
error_reporting
()
===
0
or
in_array
(
$number
,
Config
::
$items
[
'error'
][
'ignore'
])
)
if
(
error_reporting
()
===
0
)
{
{
return
;
return
;
}
}
$exception
=
new
\ErrorException
(
$error
,
$number
,
0
,
$file
,
$line
);
throw
new
\ErrorException
(
$error
,
$number
,
0
,
$file
,
$line
);
if
(
in_array
(
$number
,
Config
::
$items
[
'error'
][
'ignore'
]))
{
$logger
(
$exception
);
return
;
}
throw
$exception
;
});
});
/**
/**
...
@@ -221,4 +235,4 @@ if (Config::$items['session']['driver'] !== '')
...
@@ -221,4 +235,4 @@ if (Config::$items['session']['driver'] !== '')
IoC
::
core
(
'session'
)
->
save
(
$driver
);
IoC
::
core
(
'session'
)
->
save
(
$driver
);
}
}
$response
->
send
();
$response
->
send
();
\ No newline at end of file
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment