Hi @Spunny ,
The web api end point fires a process (which is in another dll) which is a long process using Task.Run. The web api end point is used to just fire and forget about process.
You can tell from your description.
Web Api is only used to start the process, why should errors be handled in web Api?
Just put your error handling in the corresponding DLL.
Here are the advantages of putting error handling in the DLL:
Single Responsibility Principle: Let the DLL handle exceptions by itself in line with the Single Responsibility Principle, that is, each component is responsible for its own task. The business DLL knows how to handle its exceptions, and the Web API layer does not need too much exception handling logic.
Code reuse: If you have other projects or applications that also use this business DLL, they will automatically inherit the same error handling logic without having to implement it repeatedly.
Encapsulation Details: A DLL is a separate unit that encapsulates business logic. Hiding the exception handling logic inside the DLL can prevent the Web API layer from relying too much on business details.
Best Regards,
Jiale
If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.