Program Management plugin has a lot of moving parts due to all the different levels it needs to drive: projects, users, trackers, artifacts, fields. This results in a lot of potential configuration problems.
As of today, those problems are managed disparately: some are booleans, some are exceptions, some are null checks. Exceptions in particular are currently very painful to deal with today. There can be only one single exception in-flight at any given time, which makes it hard to collect a bunch of errors. Exceptions must be caught, so we had to come up with a special ErrorCollector
class that we need to pass up and down into a lot of classes. Some exceptions extend \RuntimeException
and are unchecked, so our IDE will by default not warn us that it can be thrown.
I therefore suggest to introduce Values as errors instead of Exceptions. Exceptions are still useful in very limited and precise cases, but for the majority of our "Business errors" we would be better off with plain objects representing configuration problems. Plain objects can be collected much more easily. Now that we run on PHP 8.0, we can leverage union types to return either a valid result or an error object. This will prompt us to check if the return is valid or is an error.
Further reading on Errors vs Exceptions:
[0] https://dave.cheney.net/2012/01/18/why-go-gets-exceptions-right
[1] https://dave.cheney.net/2014/11/04/error-handling-vs-exceptions-redux
[2] https://dave.cheney.net/2015/01/26/errors-and-exceptions-redux