13

I created a CrudAppService. When I invoke its dynamic API by using swagger, I get a generic 500 error with this description:

{
  "result": null,
  "targetUrl": null,
  "success": false,
  "error": {
    "code": 0,
    "message": "An internal error occurred during your request!",
    "details": null,
    "validationErrors": null
  },
  "unAuthorizedRequest": false,
  "__abp": true
}

How can I get a more detailed exception to debug? Is there something I have to enable?

Vivek Nuna
  • 25,472
  • 25
  • 109
  • 197
pinale
  • 2,060
  • 6
  • 38
  • 72

4 Answers4

21

You can simply send the exception details to the client by enabling one of ABP's configurations (SendAllExceptionsToClients) in ***.Web.Core Module, like this:

public override void PreInitialize()
{   
    Configuration.Modules.AbpWebCommon().SendAllExceptionsToClients = true;
}

Then you get the exception details on the client. Recommended only during development.

Matheus Lacerda
  • 5,983
  • 11
  • 29
  • 45
  • I also have the mentioned problem. And the question was not about a _web project_ - it was about a lower level - _Application layer_ (CrudAppService), so we need to make some changes THERE. – Alexander May 23 '20 at 16:41
10

Check error in Logs.txt.

From the documentation on Logging:

Configuration

All configuration is done for Log4Net when you create your application from ASP.NET Boilerplate templates.

...

It's defined in the log4net.config file of the application as shown below:

<?xml version="1.0" encoding="utf-8" ?>
<log4net>
  <appender name="RollingFileAppender" type="log4net.Appender.RollingFileAppender" >
    <file value="Logs/Logs.txt" />
aaron
  • 39,695
  • 6
  • 46
  • 102
2

If you use CurrentUnitOfWork, you can catch the exception also and using UserFriendlyException you can throw the desired exception. UserFriendlyException is a specific type of exception so ABP directly shows exception message to the end user.

Example:

try
{
    await _repository.InsertAsync(...);
    await CurrentUnitOfWork.SaveChangesAsync();
}
catch(Exception ex)
{
    throw new UserFriendlyException("user friendly exception message");
}
Vivek Nuna
  • 25,472
  • 25
  • 109
  • 197
0

You could take a look into your project logs at project.Host\App_Data\Logs.txt.

janw
  • 8,758
  • 11
  • 40
  • 62
zhp
  • 11
  • 4