exception object undefined get properties?
Posted: October 25th, 2013, 4:12 pm
Hi there,
I think there is a bug in Phalanger when throwing and catching Phalanger and System exceptions.
In a /pure phalanger console program, if I throw a new System\Exception I get an Error message and the the program continue execution without going to the catch part. However, if I throw a ErrorException or OutOfRangeException exceptions with the message, severity, etc. they both go into the catch, but the exception variable gives an undefined property Notice message when accessing those 2 properties even though the object, in this case $e, has them.
Here is the code and further down the output with the error and notice messages:
Example:
The output:
I think there is a bug in Phalanger when throwing and catching Phalanger and System exceptions.
In a /pure phalanger console program, if I throw a new System\Exception I get an Error message and the the program continue execution without going to the catch part. However, if I throw a ErrorException or OutOfRangeException exceptions with the message, severity, etc. they both go into the catch, but the exception variable gives an undefined property Notice message when accessing those 2 properties even though the object, in this case $e, has them.
Here is the code and further down the output with the error and notice messages:
Example:
- Code: Select all
<?php
use System\Exception;
class Program
{
static function Main()
{
try
{
throw new System\Exception("System.Exception");
$arr = NULL;
if (is_null($arr))
{
throw new ErrorException(
"Object reference not set to an instance of an object.",
0, E_ERROR);
/*throw new S\NullReferenceException(
"Object reference not set to an instance of an object.");
throw new S\Exception(
"Object reference not set to an instance of an object.");*/
}
if (isset($arr[100][100]))
{
throw new OutOfRangeException(
"Index was outside the bounds of the array.", 0);
/*throw new \ErrorException(
"Index was outside the bounds of the array.", 0, \E_ERROR);
throw new S\IndexOutOfRangeException(
"Object reference not set to an instance of an object.");
throw new S\Exception(
"Object reference not set to an instance of an object.");*/
}
}
catch (OutOfRangeException $e)
{
echo "\nException: ", "OutOfRangeException", $e->getMessage, "\n";
}
catch (ErrorException $e)
{
echo "\nException: ", "ErrorException", $e->getSeverity, $e->getMessage, "\n";
}
catch (System\Exception $e)
{
echo "\nException: ", "Exception", $e->getMessage, "\n";
}
fgets(STDIN);
return 0;
}
}
?>
The output: