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);
        }

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

Markdown supported.
Copy, paste, or drag & drop images and files (max 100 MB per file, 100 MB total per post)

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);
    }
    
    Markdown supported.
    Copy, paste, or drag & drop images and files (max 100 MB per file, 100 MB total per post)
Boost Your Development
ABP Live Training
Packages
See Trainings
Mastering ABP Framework Book
The Official Guide
Mastering
ABP Framework
Learn More
Mastering ABP Framework Book
Made with ❤️ on ABP v10.8.0-preview. Updated on September 28, 2026, 11:44
1
ABP Assistant
🔐 You need to be logged in to use the chatbot. Please log in first.