Base solution for your next web application
Starts in:
01 DAYS
01 HRS
01 MIN
01 SEC

Activities of "antonis"

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

@ismcagdas The link you sent me does not show how can you change the exception message.

Hi,

I want to send a custom exception message to client when a specific exception is fired (AbpDbConcurrencyException). Instead of doing this for each method of all my appservices I would like to change it in a global place. So for example if I have 20 AppServices with each 2-3 methods I dont want to add try/catch block in each method but instead have a place where I do this.

How can I achieve such requirement

Thanks

@ismcagdas I think the problem is on the design of aspnetboilerplate and aspnetzero exception and error handling.

As I explained earlier:

It is possible yes but that means that I have to go on all aspnetzero crud forms (users, organization units, roles etc..) and also change their error handling behavior. The way aspnetzero team implemented error handling is not scalable and convenient at all. Their implemenation is problematic as it guides the developer to a specific direction rather than give the freedom to choose whatever is needed based on client requirements. Such a little thing but so important is implemented in a strict way.

It is possible yes but that means that I have to go on all aspnetzero crud forms (users, organization units, roles etc..) and also change their error handling behavior. The way aspnetzero team implemented error handling is not scalable and convenient at all. Their implemenation is problematic as it guides the developer to a specific direction rather than give the freedom to choose whatever is needed based on client requirements. Such a little thing but so important is implemented in a strict way. Shame

No I dont want that solution which is not convenient at all. I have dozens of CRUD forms. Some of the form needs to handle errors differently.

I want to get the response back as usual and will handle the errors by my self. This is not a solution for me

Maliming you are correct this was just quick test code to show my problem. I already did what you suggested Throw new UserFriendlyException("message") but still I get the popup on angular which I dont want to display.

I have my own logic on how to handle errors on client and I dont want to use this ugly popup

@maliming How can I use user friendly exception in my scenario since the unitofwork throws exception?

Thanks aaron

I am using aspnet core & angular and I have:

public async Task<Response> CreateClient(Client input)
        {
            input.Name = null;
            Response result = new Response();
            try
            {
                await repo.InsertAsync(input);
                await unitOfWorkManager.Current.SaveChangesAsync();
            }
            catch (Exception ex)
            {
                if (ex.InnerException != null)
                    result.ErrorMessage = ex.InnerException.Message;
                else
                    result.ErrorMessage = ex.Message;
            }
            return result;
        }

based on the fact that I set input.Name = null when await repo.SaveChangesAsync(); is called it throws an exception (Name is required). I catch the exception and have custom logic to return the response with error in it. Problem is that in client I still get this ugly popup:

which I dont want to show for custom forms. The purpose of this logic inside the app service is to avoid using the popups for CRUD and errors and instead develop using my own controls.

Showing 101 to 110 of 202 entries