•  
      request #23488 Improve errors in Program management
    Infos
    #23488
    Joris MASSON (jmasson)
    2021-12-03 15:37
    2021-11-04 10:42
    25034
    Details
    Improve errors in Program management

    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 ErrorCollectorclass 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

    Program Management
    Empty
    Empty
    • [ ] enhancement
    • [x] internal improvement
    Empty
    Stage
    Joris MASSON (jmasson)
    Reopen
    Empty
    Attachments
    Empty
    References
    Referencing request #23488
    Referenced by request #23488

    Artifact Tracker v5

    rel #22713 13.2

    Follow-ups

    User avatar
    Joris MASSON (jmasson)2021-12-03 15:37
    • Original Submission
      Something went wrong, the follow up content couldn't be loaded
      Only formatting have been changed, you should switch to markup to see the changes