How to handle results from a service [Answered]
I have the following service:
The nullable returns in some of the methods in this case indicate that the method may not find anything, except this feels a bit clunky as just a nullable return doesn't really communicate much intention and I end up having to in my API endpoints have specific cases for whether the item returned was nullable. In addition, more errors than just the item not being found could occur. I really don't wanna have to use a specific DU structure for every single method and hardcode what errors could occur as, well, I'd have to update it every time a new possible error could happen. I think I should use something like Remora.Results or some other functional result library, though I'd still like some feedback.
The nullable returns in some of the methods in this case indicate that the method may not find anything, except this feels a bit clunky as just a nullable return doesn't really communicate much intention and I end up having to in my API endpoints have specific cases for whether the item returned was nullable. In addition, more errors than just the item not being found could occur. I really don't wanna have to use a specific DU structure for every single method and hardcode what errors could occur as, well, I'd have to update it every time a new possible error could happen. I think I should use something like Remora.Results or some other functional result library, though I'd still like some feedback.