Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
Y
yii2
Project
Overview
Details
Activity
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
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
Rotua Panjaitan
yii2
Commits
1df9114b
Commit
1df9114b
authored
Apr 09, 2013
by
Qiang Xue
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
refactored ErrorException handling.
parent
79b278c8
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
40 additions
and
73 deletions
+40
-73
Application.php
framework/base/Application.php
+0
-59
ErrorException.php
framework/base/ErrorException.php
+40
-14
No files found.
framework/base/Application.php
View file @
1df9114b
...
...
@@ -87,9 +87,6 @@ class Application extends Module
*/
public
$layout
=
'main'
;
// todo
public
$localeDataPath
=
'@yii/i18n/data'
;
private
$_runtimePath
;
private
$_ended
=
false
;
...
...
@@ -165,31 +162,6 @@ class Application extends Module
if
(
ErrorException
::
isFatalErorr
(
$error
))
{
unset
(
$this
->
_memoryReserve
);
$exception
=
new
ErrorException
(
$error
[
'message'
],
$error
[
'type'
],
$error
[
'type'
],
$error
[
'file'
],
$error
[
'line'
]);
if
(
function_exists
(
'xdebug_get_function_stack'
))
{
$trace
=
array_slice
(
array_reverse
(
xdebug_get_function_stack
()),
4
,
-
1
);
foreach
(
$trace
as
&
$frame
)
{
if
(
!
isset
(
$frame
[
'function'
]))
{
$frame
[
'function'
]
=
'unknown'
;
}
// XDebug < 2.1.1: http://bugs.xdebug.org/view.php?id=695
if
(
!
isset
(
$frame
[
'type'
]))
{
$frame
[
'type'
]
=
'::'
;
}
// XDebug has a different key name
$frame
[
'args'
]
=
array
();
if
(
isset
(
$frame
[
'params'
])
&&
!
isset
(
$frame
[
'args'
]))
{
$frame
[
'args'
]
=
$frame
[
'params'
];
}
}
$ref
=
new
\ReflectionProperty
(
'Exception'
,
'trace'
);
$ref
->
setAccessible
(
true
);
$ref
->
setValue
(
$exception
,
$trace
);
}
$this
->
logException
(
$exception
);
if
((
$handler
=
$this
->
getErrorHandler
())
!==
null
)
{
...
...
@@ -295,37 +267,6 @@ class Application extends Module
date_default_timezone_set
(
$value
);
}
//
// /**
// * Returns the locale instance.
// * @param string $localeID the locale ID (e.g. en_US). If null, the {@link getLanguage application language ID} will be used.
// * @return CLocale the locale instance
// */
// public function getLocale($localeID = null)
// {
// return CLocale::getInstance($localeID === null ? $this->getLanguage() : $localeID);
// }
//
// /**
// * @return CNumberFormatter the locale-dependent number formatter.
// * The current {@link getLocale application locale} will be used.
// */
// public function getNumberFormatter()
// {
// return $this->getLocale()->getNumberFormatter();
// }
//
// /**
// * Returns the locale-dependent date formatter.
// * @return CDateFormatter the locale-dependent date formatter.
// * The current {@link getLocale application locale} will be used.
// */
// public function getDateFormatter()
// {
// return $this->getLocale()->getDateFormatter();
// }
//
/**
* Returns the database connection component.
* @return \yii\db\Connection the database connection
...
...
framework/base/ErrorException.php
View file @
1df9114b
...
...
@@ -7,6 +7,8 @@
namespace
yii\base
;
use
Yii
;
/**
* ErrorException represents a PHP error.
*
...
...
@@ -33,6 +35,30 @@ class ErrorException extends Exception
$this
->
severity
=
$severity
;
$this
->
file
=
$filename
;
$this
->
line
=
$lineno
;
if
(
function_exists
(
'xdebug_get_function_stack'
))
{
$trace
=
array_slice
(
array_reverse
(
xdebug_get_function_stack
()),
3
,
-
1
);
foreach
(
$trace
as
&
$frame
)
{
if
(
!
isset
(
$frame
[
'function'
]))
{
$frame
[
'function'
]
=
'unknown'
;
}
// XDebug < 2.1.1: http://bugs.xdebug.org/view.php?id=695
if
(
!
isset
(
$frame
[
'type'
]))
{
$frame
[
'type'
]
=
'::'
;
}
// XDebug has a different key name
$frame
[
'args'
]
=
array
();
if
(
isset
(
$frame
[
'params'
])
&&
!
isset
(
$frame
[
'args'
]))
{
$frame
[
'args'
]
=
$frame
[
'params'
];
}
}
$ref
=
new
\ReflectionProperty
(
'Exception'
,
'trace'
);
$ref
->
setAccessible
(
true
);
$ref
->
setValue
(
$this
,
$trace
);
}
}
/**
...
...
@@ -62,20 +88,20 @@ class ErrorException extends Exception
public
function
getName
()
{
$names
=
array
(
E_ERROR
=>
\
Yii
::
t
(
'yii|Fatal Error'
),
E_PARSE
=>
\
Yii
::
t
(
'yii|Parse Error'
),
E_CORE_ERROR
=>
\
Yii
::
t
(
'yii|Core Error'
),
E_COMPILE_ERROR
=>
\
Yii
::
t
(
'yii|Compile Error'
),
E_USER_ERROR
=>
\
Yii
::
t
(
'yii|User Error'
),
E_WARNING
=>
\
Yii
::
t
(
'yii|Warning'
),
E_CORE_WARNING
=>
\
Yii
::
t
(
'yii|Core Warning'
),
E_COMPILE_WARNING
=>
\
Yii
::
t
(
'yii|Compile Warning'
),
E_USER_WARNING
=>
\
Yii
::
t
(
'yii|User Warning'
),
E_STRICT
=>
\
Yii
::
t
(
'yii|Strict'
),
E_NOTICE
=>
\
Yii
::
t
(
'yii|Notice'
),
E_RECOVERABLE_ERROR
=>
\
Yii
::
t
(
'yii|Recoverable Error'
),
E_DEPRECATED
=>
\
Yii
::
t
(
'yii|Deprecated'
),
E_ERROR
=>
Yii
::
t
(
'yii|Fatal Error'
),
E_PARSE
=>
Yii
::
t
(
'yii|Parse Error'
),
E_CORE_ERROR
=>
Yii
::
t
(
'yii|Core Error'
),
E_COMPILE_ERROR
=>
Yii
::
t
(
'yii|Compile Error'
),
E_USER_ERROR
=>
Yii
::
t
(
'yii|User Error'
),
E_WARNING
=>
Yii
::
t
(
'yii|Warning'
),
E_CORE_WARNING
=>
Yii
::
t
(
'yii|Core Warning'
),
E_COMPILE_WARNING
=>
Yii
::
t
(
'yii|Compile Warning'
),
E_USER_WARNING
=>
Yii
::
t
(
'yii|User Warning'
),
E_STRICT
=>
Yii
::
t
(
'yii|Strict'
),
E_NOTICE
=>
Yii
::
t
(
'yii|Notice'
),
E_RECOVERABLE_ERROR
=>
Yii
::
t
(
'yii|Recoverable Error'
),
E_DEPRECATED
=>
Yii
::
t
(
'yii|Deprecated'
),
);
return
isset
(
$names
[
$this
->
getCode
()])
?
$names
[
$this
->
getCode
()]
:
\
Yii
::
t
(
'yii|Error'
);
return
isset
(
$names
[
$this
->
getCode
()])
?
$names
[
$this
->
getCode
()]
:
Yii
::
t
(
'yii|Error'
);
}
}
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