Overview
KB
Technical FAQ
PHP Manual
CSS2 Manual
HTML Manual
JS Guide
JS Reference
PhpDock Manual
Nu-Coder Manual
PhpExpress Manual
PHP Joomla
Development
Learn PHP
 
<Yaf_ExceptionYaf_Exception::getPrevious>
^Yaf_ExceptionLast updated: Mon, 26 Oct 2026

Yaf_Exception::__construct

(Yaf >=1.0.0)

Yaf_Exception::__construct — Construct a Yaf exception

Description

public function Yaf_Exception::__construct(string $message = "", int $code = 0)

Constructs a new Yaf_Exception. The code carries the Yaf error code that identifies the type of failure, and is exposed via Exception::getCode().

Parameters

message

The exception message.

code

The Yaf error code.

Return Values

No value is returned.

Examples

Example #1 Yaf_Exception::__construct() example

<?php
throw new Yaf_Exception(
    "Failed to find the controller 'Product'",
    YAF_ERR_NOTFOUND_CONTROLLER /* 516 */
);
?>

The above example will output something similar to:

PHP Fatal error:  Uncaught Yaf_Exception: Failed to find the controller 'Product' in /path/to/index.php:2

See Also


<Yaf_ExceptionYaf_Exception::getPrevious>
^Yaf_ExceptionLast updated: Mon, 26 Oct 2026