exception object undefined get properties?
4 posts
• Page 1 of 1
exception object undefined get properties?
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:
You do not have the required permissions to view the files attached to this post.
- carlosqt
- Posts: 7
- Joined: March 10th, 2013, 7:21 pm
Re: exception object undefined get properties?
Thank your for reporting the issue.
- Throwing System\Exception has been fixed.
- Add accessing PHP Exception message and severity; getSeverity() and getMessage() are methods (not properties) so there is missing "()" in your sample. To access System\Exception message, use ->Message property.
Regards,
- Throwing System\Exception has been fixed.
- Add accessing PHP Exception message and severity; getSeverity() and getMessage() are methods (not properties) so there is missing "()" in your sample. To access System\Exception message, use ->Message property.
Regards,
Jakub Misek │ DEVSENSE s.r.o. | @misekjakub │ jakub@devsense.com │
-
Jakub Misek - Posts: 2092
- Joined: January 4th, 2012, 2:42 pm
- Location: Prague
Re: exception object undefined get properties?
Great its now fixed. Will look at it when a new release is available.
Regarding the method call instead of a property shame on me lol, definitely I was a bit out of focus. I added the parenthesis () to both calls and they worked as expected.
Thanks for your quick response.
Best Regards,
Carlos
Regarding the method call instead of a property shame on me lol, definitely I was a bit out of focus. I added the parenthesis () to both calls and they worked as expected.
Thanks for your quick response.
Best Regards,
Carlos
- carlosqt
- Posts: 7
- Joined: March 10th, 2013, 7:21 pm
Re: exception object undefined get properties?
Great it works Thank you for giving us know!
Jakub Misek │ DEVSENSE s.r.o. | @misekjakub │ jakub@devsense.com │
-
Jakub Misek - Posts: 2092
- Joined: January 4th, 2012, 2:42 pm
- Location: Prague
4 posts
• Page 1 of 1
Who is online
Users browsing this forum: No registered users and 11 guests