Closed devbrsa closed 1 month ago
Hi everyone,
Does anyone have an example or suggestions on how to implement monads or the result pattern with MediatR?
I’m looking for a way to return a Result with errors instead of throwing exceptions during validation, and registering this in the pipeline behavior.
Result
Or a way to make the pipeline behavior always work with Result types.
Most examples I’ve found either rely on throwing exceptions or using libraries like ErrorOr, which is great, but I’m aiming for a simpler Result type.
ErrorOr
Cheers, Thanks!
There are plenty of libraries that can help you with that:
error-or
But I do warn you to be careful not do overdo it. Heavily personalized code is a nightmare to read for outsiders.
Hi everyone,
Does anyone have an example or suggestions on how to implement monads or the result pattern with MediatR?
I’m looking for a way to return a
Result
with errors instead of throwing exceptions during validation, and registering this in the pipeline behavior.Or a way to make the pipeline behavior always work with Result types.
Most examples I’ve found either rely on throwing exceptions or using libraries like
ErrorOr
, which is great, but I’m aiming for a simplerResult
type.Cheers, Thanks!