diff --git a/Controllers/QuoteController.cs b/Controllers/QuoteController.cs index 2a85bed..2d83a00 100644 --- a/Controllers/QuoteController.cs +++ b/Controllers/QuoteController.cs @@ -54,10 +54,21 @@ public class QuotesController : ControllerBase var totalQuotes = await _db.Quotes.CountAsync(); const int PageSize = 10; - List? categories = category_id? - .Split(",") - .Select(Int32.Parse) - .ToList(); + List? categories; + try + { + categories = category_id? + .Split(",") + .Select(Int32.Parse) + .ToList(); + } catch + { + // Try to catch badly formatted requests + return BadRequest(new ErrorDTO { + Status = "error", + Error_msg = "Category_id can be either an integer, or comma separated integers" + }); + } if (page_no <= 0) {