Open Closed

Show the exception msg #8830


User avatar
0
LiSong created
  • ABP Framework version: v0.X.X

  • UI Type: MVC

  • Database System: SQL Server

  • Tiered (for MVC) or Auth Server Separated (for Angular): no

  • Exception message and full stack trace:

  • Steps to reproduce the issue:

I have created a CRUD page, and I added a logic to check for the delete button:

        [Authorize(TappPermissions.TappOrganizations.Delete)]
        public override async Task DeleteAsync(Guid id)
        {
            var users = await _tappOrganizationUsersAppService.GetListAsync(new GetTappOrganizationUsersInput()
            {
                TappOrganization = id,
                MaxResultCount = 1
            });

            if (users.Items.Any())
                throw new Exception("This organization can't be deleted because it has users associated with it.");

            await _tappOrganizationRepository.DeleteAsync(id);
        }

Screenshot 2025-02-19 173703.png

and I am trying to show the exception message on this pop up window. how can I do that?
thanks


1 Answer(s)
  • User Avatar
    0
    enisn created
    Support Team .NET Developer

    Can you try UserFriendlyException instead of Exception?

    [Authorize(TappPermissions.TappOrganizations.Delete)]
    public override async Task DeleteAsync(Guid id)
    {
        var users = await _tappOrganizationUsersAppService.GetListAsync(new GetTappOrganizationUsersInput()
        {
            TappOrganization = id,
            MaxResultCount = 1
        });
    
        if (users.Items.Any())
            throw new UserFriendlyException("This organization can't be deleted because it has users associated with it.");
    
        await _tappOrganizationRepository.DeleteAsync(id);
    }
    
Boost Your Development
ABP Live Training
Packages
See Trainings
Mastering ABP Framework Book
Do you need assistance from an ABP expert?
Schedule a Meeting
Mastering ABP Framework Book
The Official Guide
Mastering
ABP Framework
Learn More
Mastering ABP Framework Book
Made with ❤️ on ABP v9.2.0-preview. Updated on March 18, 2025, 10:42