From e7b737a3dd6ffbe1f5150b79d5539c812e6bc2ee Mon Sep 17 00:00:00 2001 From: martinshoob Date: Mon, 11 Aug 2025 21:23:49 +0200 Subject: [PATCH] Add error messages --- DrinkRateAPI/AuthorizationPolicies/AdminOnlyRequirement.cs | 2 +- DrinkRateAPI/Services/ProductTableService.cs | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/DrinkRateAPI/AuthorizationPolicies/AdminOnlyRequirement.cs b/DrinkRateAPI/AuthorizationPolicies/AdminOnlyRequirement.cs index c6d18a2..384290e 100644 --- a/DrinkRateAPI/AuthorizationPolicies/AdminOnlyRequirement.cs +++ b/DrinkRateAPI/AuthorizationPolicies/AdminOnlyRequirement.cs @@ -35,7 +35,7 @@ public class AdminOnlyHandler : AuthorizationHandler } catch (NotFoundException _) { - throw new ForbiddenException(); + throw new ForbiddenException("You need to be logged in to do this action."); } if (_userProfileService.IsUserProfileAdmin(userProfile)) diff --git a/DrinkRateAPI/Services/ProductTableService.cs b/DrinkRateAPI/Services/ProductTableService.cs index c10506f..e05d83b 100644 --- a/DrinkRateAPI/Services/ProductTableService.cs +++ b/DrinkRateAPI/Services/ProductTableService.cs @@ -15,8 +15,8 @@ public class ProductTableService(ApplicationDbContext context) { var productTable = 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 { ProductTableName = productTable.ProductTableName,