C
C#2y ago
barcode

✅ MediatR exceptions

I am building an API having business logic in another layer and when validation error occurs I catch it, where should I handle this exception, should I handle it in the API like
// try
var dtos = await _mediator.Send(getCentersQuery);
return Ok(dtos);

// catch (validationException)
// ....
// try
var dtos = await _mediator.Send(getCentersQuery);
return Ok(dtos);

// catch (validationException)
// ....
or is there a better way?
4 Replies
Saber
Saber2y ago
global exception handler
barcode
barcodeOP2y ago
like an Unhandled exception handler?
JakenVeina
JakenVeina2y ago
or a post request handler within MediatR
barcode
barcodeOP2y ago
where should this be handled? checked a few example projects and can't find where it is being handled it must be somewhere I just can't find it over all abstraction 😐 found it, it is in the API i will implement one there as well
Want results from more Discord servers?
Add your server