Hi, i'd like to catch a BusinessException in a DistributedHandler(IDistributedEventHandler) from an api call , i put [UnitOfWork(true)] attribute in both classes and verify i m in same uow but i only got error : TypeError: Failed to fetch,
Any clue ?
Thanks.
Fred.
3 Answer(s)
-
0
Hi,
Can you provide sample codes that explains your case?
As I uınderstand, you inject a service inside your EventHandler and trying to catch exception that is thrown in that injected service or any of it's dependencies, right?
Normally you can catch them, if you do not catch and throw an exception from a handler, that makes that execution is failed and it'll be re-tried. If you don't want to execute that handler again, you should handle and don't throw exception in the handler
-
0
Hi enisn :
for example i got a IDistributedEventHandler witch got an error
public class OrderHandler : IDistributedEventHandler, ITransientDependency { private readonly OrderReservationManager _orderReservationManager; public OrderHandler(OrderReservationManager orderReservationManager) { _orderReservationManager = orderReservationManager; } public async Task HandleEventAsync(OrderEto eventData) { _orderReservationManager.ThrowError(); } }
call by this from another domain :
public class StockAppService : IStockAppService { private readonly IStockRepository _stockRepository; public StockAppService(IStockRepository stockRepository) { _stockRepository = stockRepository; } public virtual async Task<Guid> OrderItemAsync(FieldPlanCreateDto input) { await _stockRepository.UpdateStock(input.item); AddDistributedEvent(new OrderEto { Item = input.item }); } }
if i got an error on StockAppService , error is return correctly(_AbpErrorFormat, error.Data in json) but an error HandleEventAsync always return TypeError: Failed to fetch.
-
0
Are they running on the same instance of application? Or you're using in a micro-service project?