How to get more detailed exception in ABP?

坚强是说给别人听的谎言 提交于 2019-12-03 13:43:38

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" />
Pradeep Raj Thapaliya

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.

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");
}
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!