exception object undefined get properties?

Discussion about the open-source Phalanger [?] project.

exception object undefined get properties?

Postby carlosqt » 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:

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;
   }
}

?>


exceptions.png



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?

Postby Jakub Misek » October 26th, 2013, 2:49 pm

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,
Jakub Misek │ DEVSENSE s.r.o. │ Email: jakub@devsense.com
User avatar
Jakub Misek
 
Posts: 2062
Joined: January 4th, 2012, 2:42 pm
Location: Prague

Re: exception object undefined get properties?

Postby carlosqt » October 30th, 2013, 8:12 am

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
carlosqt
 
Posts: 7
Joined: March 10th, 2013, 7:21 pm

Re: exception object undefined get properties?

Postby Jakub Misek » October 30th, 2013, 5:55 pm

Great it works :-) Thank you for giving us know!
Jakub Misek │ DEVSENSE s.r.o. │ Email: jakub@devsense.com
User avatar
Jakub Misek
 
Posts: 2062
Joined: January 4th, 2012, 2:42 pm
Location: Prague


Return to Phalanger project

Who is online

Users browsing this forum: No registered users and 1 guest

cron

User Control Panel

Login

Who is online

In total there is 1 user online :: 0 registered, 0 hidden and 1 guest (based on users active over the past 5 minutes)
Most users ever online was 62 on January 7th, 2012, 10:54 pm

Users browsing this forum: No registered users and 1 guest
Phalanger