I am wondering what is the best practice for including class specific exception files.
Say we have an init exception that extends base exception that extends Exception. Should these exceptions be included in global application scope or at the top of the class files they can throw from with include_once?
I know both methods work, but for testing it seems having the file included at the top would be easier as the dependency would be included with the class file.
They should only be included with the module that they are attached to. It doesn’t make much sense to throw an exception for a module that isn’t loaded. So when you load the module, load the exceptions as well. This can done in the module init code or simply including the file on top of the main module file.