PHP Class yii\web\HttpException

HttpException can be differentiated via its [[statusCode]] property value which keeps a standard HTTP status code (e.g. 404, 500). Error handlers may use this status code to decide how to format the error page. Throwing an HttpException like in the following example will result in the 404 page to be displayed. php if ($item === null) { // item does not exist throw new \yii\web\HttpException(404, 'The requested Item could not be found.'); }
Since: 2.0
Author: Qiang Xue ([email protected])
Inheritance: extends yii\base\UserException
Show file Open project: yiisoft/yii2 Class Usage Examples

Public Properties

Property Type Description
$statusCode HTTP status code, such as 403, 404, 500, etc.

Public Methods

Method Description
__construct ( integer $status, string $message = null, integer $code, Exception $previous = null ) Constructor.
getName ( ) : string

Method Details

__construct() public method

Constructor.
public __construct ( integer $status, string $message = null, integer $code, Exception $previous = null )
$status integer HTTP status code, such as 404, 500, etc.
$message string error message
$code integer error code
$previous Exception The previous exception used for the exception chaining.

getName() public method

public getName ( ) : string
return string the user-friendly name of this exception

Property Details

$statusCode public property

HTTP status code, such as 403, 404, 500, etc.
public $statusCode