doctrine / dbal

Doctrine Database Abstraction Layer
https://www.doctrine-project.org/projects/dbal.html
MIT License
9.4k stars 1.33k forks source link

Why some places you use throw new Exception and other static method? #6424

Closed eerison closed 4 weeks ago

eerison commented 4 weeks ago

Hello guys it is just for a question that came up in our team, and the guy used this repo as example.

Do you have the initial discussion for when you decided to use throw Exception::new(); instead of throw new Exception();

and I see that some places you are using throw new and others with static method.

e.g:

Thank you in advance.

derrabus commented 4 weeks ago

Static constructor methods help us standardize how we derive the exception message from given input, in your example an invalid class name.

eerison commented 4 weeks ago

But Couldn't you do like this too?

throw new InvalidWrapperClass($wrapperClass); 
derrabus commented 4 weeks ago

Sure.