Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DDC-260: Add additional info to ReflectionException in ClassMetadata #3330

Closed
doctrinebot opened this issue Jan 16, 2010 · 6 comments
Closed

Comments

@doctrinebot
Copy link

Jira issue originally created by user shurakai:

I was thinking about adding an additional exception to the ClassMetadata class. For example when using reflection for recieving an attribute and an exception is raised (for example because the attribute does not exist), the debug information could be improved. I thought one could catch the ReflectionException and throw a DoctrineReflectionException or something like that and add some additional information like what the name of the currently processed class is

@doctrinebot
Copy link
Author

Comment created by romanb:

I dont think that would be overly useful as the exceptions from php are pretty good. Can you show an example of the error, the message you get and the improved message you would like to get instead?

@doctrinebot
Copy link
Author

Comment created by shurakai:

Hi Roman,

i ran the doctrine CLI tool and tried "schema-tool". One of my PHP entities classes hadn't all properties defined in my YAML files (I'm wondering why Doctrine needs to perform Reflection on my PHP classes when converting from YAML...?) and I recieve this error:

{quote} PHP Fatal error: Uncaught exception 'ReflectionException' with message 'Property children does not exist' in /var/workspaces/project/library/Doctrine/ORM/Mapping/ClassMetadata.php:244
Stack trace:
#0 /var/workspaces/project/library/Doctrine/ORM/Mapping/ClassMetadata.php(244): ReflectionClass->getProperty('children')
#1 /var/workspaces/project/library/Doctrine/ORM/Mapping/ClassMetadataInfo.php(1298): Doctrine\ORM\Mapping\ClassMetadata->_storeAssociationMapping(Object(Doctrine\ORM\Mapping\OneToManyMapping))
#2 /var/workspaces/project/library/Doctrine/ORM/Mapping/Driver/YamlDriver.php(266): Doctrine\ORM\Mapping\ClassMetadataInfo->mapOneToMany(Array)
#3 /var/workspaces/project/library/Doctrine/ORM/Mapping/ClassMetadataFactory.php(195): Doctrine\ORM\Mapping\Driver\YamlDriver->loadMetadataForClass('Core\Block\Item...', Object(Doctrine\ORM\Mapping\ClassMetadata))
#4 /var/workspaces/project/library/Doctrine/ORM/Mapping/ClassMetadataFactory.php(111): Doctrine\ORM\Mapping\ClassMetadataFactory->_loadMetadata('Core\Block\Item...')
#5 /va in /var/workspaces/project/library/Doctrine/ORM/Mapping/ClassMetadata.php on line 244
{quote}

The problem here is, that I'm not told in which class the problem occurs because PHP automatically shortens the parameters displayed. Therefore, I need to guess, and thats definitely something I don't want to do.

The errormessage I'd like to see:

. The error occurred in class .

So in this case:

{quote}Property children does not exist. The error occurred in class Core\Block\Item\Panel\AbstractPanel{quote}

@doctrinebot
Copy link
Author

Comment created by shurakai:

This should fix this issue

@doctrinebot
Copy link
Author

Comment created by @guilhermeblanco:

In r7041 this issue was fixed.

Thanks for the patch!

@doctrinebot
Copy link
Author

Issue was closed with resolution "Fixed"

@doctrinebot
Copy link
Author

Imported 1 attachments from Jira into https://gist.github.com/9b82263fa4659f96cab3

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant