Is there a name for the patterns used send messages/errors and results through an application's layers from business logic/database to the UI? What is the modern way?
For example: The application layers are setup as follows: UI <-> ViewModel <-> Business Logic <-> Database/Repository
A user wants to update a record, it's straight forward to pass that information down through the layers. If the update transaction passes or fails, I'd like to return something back to the UI. If there was a reason the update failed, I'd like to capture the reason and send that back to the UI.
In my case, I am returning a tuple<bool, string>
where the bool is success/fail and string is the error message. Is this bad practice?
- Should I be creating a "Result" class?
- Are there other patterns or existing framework objects/type that do this?
- Should the business logic class own/create the error strings for the UI? (I think yes, but tell me otherwise)
I came across this library: OneOf But not sure I want to implement this.
Aucun commentaire:
Enregistrer un commentaire