doctrine/mongodb — pull request #155 by blockjon (2014-02-11 01:30:16+00:00)
Title: Exception callback handler proposal

I have come across a situation where I must instrument the exceptions that doctrine/mongodb is throwing. I am a user of the Doctrine ODM so eventually, I would like some simple way to instrument any exception that is generated from within the Doctrine world.

After reviewing my options and discussing this w/ ocramius, I thought I would share the idea in this pull request with the maintainers to see if you all agree this would be a good addition to doctrine/mongodb.

In my watered down example, you see I have created a new Event type called "preThrowException" which I have set to trigger just before an exception is thrown.

If the Doctrine upstream maintainers think this would be a positive addition, I could go through the codebase and apply this pattern to everywhere I see the code throwing an exception.

Could you please advise? Perhaps there's a better pattern?