Base solution for your next web application
Open Closed

Custom Exception filter apply only to custom module #6013


User avatar
0
antonis created

Hi,

I have created a new custom module (CustomModule) and I want to handle exceptions thrown in appservices of this module. For that I have created a customexception filter and have added following code into the PreInitialize

Configuration.ReplaceService<IExceptionFilter, CustomModuleExceptionFilter>(Abp.Dependency.DependencyLifeStyle.Transient);.

The problem I have is that the CustomModuleExceptionFilter is not only fired from exceptions triggered in the CustomModule but also from exceptions fired on all other modules. Is there any way to limit this filter to be applied only to CustomModule?

Thanks


3 Answer(s)
  • User Avatar
    0
    ismcagdas created
    Support Team

    Hi @antonis

    I think it is not possible. You need to add an extra information to your exceptions on CustomModule and check them in CustomModuleExceptionFilter.

    A note: if you replace IExceptionFilter with CustomModuleExceptionFilter, ABP's default implementation will not work at all.

  • User Avatar
    0
    antonis created

    That is a shame. It would be nice to have this feature. Is it possible to implement?

  • User Avatar
    0
    ismcagdas created
    Support Team

    @antonis I'm not sure at the moment. You can create a feture request to ABP Framework but it is not sure that this faeture will be implemented in a short time even if we decide to implement it.

    For now, you can try to follow my suggestion https://support.aspnetzero.com/QA/Questions/6013#answer-70e01884-e37e-c716-dd6e-39ea4e0202b3.