Q:

replace die to stop process

I'm using die to stop the process when I get an error:
main class:
class myClass {

    public function myMethod () {

        $helper->checkParameter( $thisParameterCanNotBeEmpty );

    }

}

and my helper
class control {

    public function checkParameter ( $param ) {

        if ( $param == "" ) {

            echo "parameter can not be empty";
            die;

        }

    }

}

like that if the parameter is empty I have an error message and the process is stopped.
But my problem is now I want to use unit tests (with PHPUnit) and the die stop the process (ok) and the unit tests execution (not ok).
With Zend 1.12, is it possible to stop the process with calling view or something instead of kill all the php process ?
Thx

A:

Like @Leggendario said, use must use exceptions.
class control
{
    public function checkParameter ( $param )
    {
        if ( $param == "" ) {
            throw new \Exception("parameter can not be empty");
        }
    }
}

The \ before Exception tells PHP to use its built in namespace for the exception.

