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
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
PSDI Army
yii2
Commits
398ac254
Commit
398ac254
authored
Feb 03, 2013
by
Qiang Xue
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
added UserException.
parent
af4455eb
Show whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
31 additions
and
35 deletions
+31
-35
Application.php
framework/base/Application.php
+1
-1
ErrorHandler.php
framework/base/ErrorHandler.php
+2
-2
Exception.php
framework/base/Exception.php
+0
-5
HttpException.php
framework/base/HttpException.php
+1
-5
InvalidRequestException.php
framework/base/InvalidRequestException.php
+1
-6
InvalidRouteException.php
framework/base/InvalidRouteException.php
+1
-6
UserException.php
framework/base/UserException.php
+21
-0
Application.php
framework/console/Application.php
+1
-2
Exception.php
framework/console/Exception.php
+1
-6
HelpController.php
framework/console/controllers/HelpController.php
+2
-2
No files found.
framework/base/Application.php
View file @
398ac254
...
...
@@ -464,7 +464,7 @@ class Application extends Module
*/
public
function
renderException
(
$exception
)
{
if
(
$exception
instanceof
Exception
&&
(
$exception
->
causedByUser
||
!
YII_DEBUG
))
{
if
(
$exception
instanceof
Exception
&&
(
$exception
instanceof
UserException
||
!
YII_DEBUG
))
{
$message
=
$exception
->
getName
()
.
': '
.
$exception
->
getMessage
();
}
else
{
$message
=
YII_DEBUG
?
(
string
)
$exception
:
'Error: '
.
$exception
->
getMessage
();
...
...
framework/base/ErrorHandler.php
View file @
398ac254
...
...
@@ -81,7 +81,7 @@ class ErrorHandler extends Component
\Yii
::
$application
->
renderException
(
$exception
);
}
else
{
$view
=
new
View
(
$this
);
if
(
!
YII_DEBUG
||
$exception
instanceof
Exception
&&
$exception
->
causedByUser
)
{
if
(
!
YII_DEBUG
||
$exception
instanceof
UserException
)
{
$viewName
=
$this
->
errorView
;
}
else
{
$viewName
=
$this
->
exceptionView
;
...
...
@@ -256,7 +256,7 @@ class ErrorHandler extends Component
public
function
renderAsHtml
(
$exception
)
{
$view
=
new
View
(
$this
);
if
(
!
YII_DEBUG
||
$exception
instanceof
Exception
&&
$exception
->
causedByUser
)
{
if
(
!
YII_DEBUG
||
$exception
instanceof
UserException
)
{
$viewName
=
$this
->
errorView
;
}
else
{
$viewName
=
$this
->
exceptionView
;
...
...
framework/base/Exception.php
View file @
398ac254
...
...
@@ -18,11 +18,6 @@ namespace yii\base;
class
Exception
extends
\Exception
{
/**
* @var boolean whether this exception is caused by end user's mistake (e.g. wrong URL)
*/
public
$causedByUser
=
false
;
/**
* @return string the user-friendly name of this exception
*/
public
function
getName
()
...
...
framework/base/HttpException.php
View file @
398ac254
...
...
@@ -19,16 +19,12 @@ namespace yii\base;
* @author Qiang Xue <qiang.xue@gmail.com>
* @since 2.0
*/
class
HttpException
extends
Exception
class
HttpException
extends
User
Exception
{
/**
* @var integer HTTP status code, such as 403, 404, 500, etc.
*/
public
$statusCode
;
/**
* @var boolean whether this exception is caused by end user's mistake (e.g. wrong URL)
*/
public
$causedByUser
=
true
;
/**
* Constructor.
...
...
framework/base/InvalidRequestException.php
View file @
398ac254
...
...
@@ -15,14 +15,9 @@ namespace yii\base;
* @author Qiang Xue <qiang.xue@gmail.com>
* @since 2.0
*/
class
InvalidRequestException
extends
\
Exception
class
InvalidRequestException
extends
User
Exception
{
/**
* @var boolean whether this exception is caused by end user's mistake (e.g. wrong URL)
*/
public
$causedByUser
=
true
;
/**
* @return string the user-friendly name of this exception
*/
public
function
getName
()
...
...
framework/base/InvalidRouteException.php
View file @
398ac254
...
...
@@ -15,14 +15,9 @@ namespace yii\base;
* @author Qiang Xue <qiang.xue@gmail.com>
* @since 2.0
*/
class
InvalidRouteException
extends
\
Exception
class
InvalidRouteException
extends
User
Exception
{
/**
* @var boolean whether this exception is caused by end user's mistake (e.g. wrong URL)
*/
public
$causedByUser
=
true
;
/**
* @return string the user-friendly name of this exception
*/
public
function
getName
()
...
...
framework/base/UserException.php
0 → 100644
View file @
398ac254
<?php
/**
* UserException class file.
*
* @link http://www.yiiframework.com/
* @copyright Copyright © 2008 Yii Software LLC
* @license http://www.yiiframework.com/license/
*/
namespace
yii\base
;
/**
* UserException is the base class for exceptions that are meant to be shown to end users.
* Such exceptions are often caused by mistakes of end users.
*
* @author Qiang Xue <qiang.xue@gmail.com>
* @since 2.0
*/
class
UserException
extends
Exception
{
}
framework/console/Application.php
View file @
398ac254
...
...
@@ -126,8 +126,7 @@ class Application extends \yii\base\Application
'message'
=>
'yii\console\controllers\MessageController'
,
'help'
=>
'yii\console\controllers\HelpController'
,
'migrate'
=>
'yii\console\controllers\MigrateController'
,
'shell'
=>
'yii\console\controllers\ShellController'
,
'create'
=>
'yii\console\controllers\CreateController'
,
'app'
=>
'yii\console\controllers\CreateController'
,
);
}
...
...
framework/console/Exception.php
View file @
398ac254
...
...
@@ -15,14 +15,9 @@ namespace yii\console;
* @author Qiang Xue <qiang.xue@gmail.com>
* @since 2.0
*/
class
Exception
extends
\yii\base\Exception
class
Exception
extends
\yii\base\
User
Exception
{
/**
* @var boolean whether this exception is caused by end user's mistake (e.g. wrong URL)
*/
public
$causedByUser
=
true
;
/**
* @return string the user-friendly name of this exception
*/
public
function
getName
()
...
...
framework/console/controllers/HelpController.php
View file @
398ac254
...
...
@@ -52,7 +52,7 @@ class HelpController extends Controller
* @return integer the exit status
* @throws Exception if the command for help is unknown
*/
public
function
actionIndex
(
$command
)
public
function
actionIndex
(
$command
=
null
)
{
if
(
$command
!==
null
)
{
$result
=
Yii
::
$application
->
createController
(
$command
);
...
...
@@ -147,7 +147,7 @@ class HelpController extends Controller
if
(
$commands
!==
array
())
{
echo
"The following commands are available:
\n\n
"
;
foreach
(
$commands
as
$command
)
{
echo
"
*
$command
\n
"
;
echo
"*
$command
\n
"
;
}
echo
"
\n
To see the help of each command, enter:
\n
"
;
echo
"
\n
yiic help <command-name>
\n\n
"
;
...
...
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