Add error messages

This commit is contained in:
martinshoob 2025-08-11 21:23:49 +02:00
parent 69573991ca
commit e7b737a3dd
2 changed files with 3 additions and 3 deletions

View file

@ -35,7 +35,7 @@ public class AdminOnlyHandler : AuthorizationHandler<AdminOnlyRequirement>
} }
catch (NotFoundException _) catch (NotFoundException _)
{ {
throw new ForbiddenException(); throw new ForbiddenException("You need to be logged in to do this action.");
} }
if (_userProfileService.IsUserProfileAdmin(userProfile)) if (_userProfileService.IsUserProfileAdmin(userProfile))

View file

@ -15,8 +15,8 @@ public class ProductTableService(ApplicationDbContext context)
{ {
var productTable = var productTable =
await _context.ProductTable.FirstOrDefaultAsync(x => x.ProductTableName == productTableName) ?? await _context.ProductTable.FirstOrDefaultAsync(x => x.ProductTableName == productTableName) ??
throw new NotFoundException(); throw new NotFoundException($"Product table with the name {productTableName} not found.");
return new ProductTableGet return new ProductTableGet
{ {
ProductTableName = productTable.ProductTableName, ProductTableName = productTable.ProductTableName,