Search code examples
exception.net-coreswaggeraspnetboilerplateabp-framework

Exception details in ABP framework


I wanna return the details of exception with ABP .NET Core, what I noticed is when I go to AbpAuditLogs table and App_Data\Logs logFile they contain the exception in details but when I use below method to return the exception it shows only general exception without any details (500 Internal Server Error)

try{
:
:
:
}
catch (Exception ex)
{
                throw new System.ArgumentException(ex.InnerException.Message.ToString(), "original");
}

So, How could I return the specific Exception for the user for Example Email Validation Exception and so on?

Update:

I will explain more to make the question more clear :

The way that I handled the exception is attached with this question above . The problem is when hitting a request on the service from swagger or Postman always see General Error with status Code 500 without any details and that force me to review the details of the exception from Log File or Log Table , I wanna see the details of the exception (e.g FileNotFoundException ) directly from Swagger or Postman without return back to Log File or AbpAuditLogs Table.


Solution

  • Actually, I found the answer in this question for @Mehdi Daustany .what I did is exactly what @Mehdi Daustany answered, I've added below code :

       if (_env.EnvironmentName.ToLower() == "development")
        Configuration.Modules.AbpWebCommon().SendAllExceptionsToClients = true;
    

    under ***.Web.Core then the details of exception appeared in the Swagger