From cce05b2179aeac32ec8432e063a2c4bbe466042c Mon Sep 17 00:00:00 2001 From: Xander Sigler Date: Thu, 7 Dec 2023 19:08:23 -0800 Subject: [PATCH] Add error message if no valid day was found --- AdventOfCode/Controllers/AdventOfCodeController.cs | 7 ++++++- AdventOfCode/Startup.cs | 2 +- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/AdventOfCode/Controllers/AdventOfCodeController.cs b/AdventOfCode/Controllers/AdventOfCodeController.cs index ac018ec..ce74de0 100644 --- a/AdventOfCode/Controllers/AdventOfCodeController.cs +++ b/AdventOfCode/Controllers/AdventOfCodeController.cs @@ -25,7 +25,12 @@ namespace AdventOfCode.Controllers { _logger.LogInformation($"Recieving a request for {year} day {day} version {version} with {(IgnoreLogMessages ? "no" : "")}logs"); AOCRequest request = new AOCRequest() { Input = input, Version = version, IgnoreLogMessages = IgnoreLogMessages }; - var resp = GetAOCDay(year, day).ExecuteDay(request); + var aocDay = GetAOCDay(year, day); + if (aocDay == null) + { + return new AOCResponse() { Status = false, StackTrace = $"Year {2023} Day {day} part {version} is not available at this time!" }; + } + var resp = aocDay.ExecuteDay(request); return resp; } diff --git a/AdventOfCode/Startup.cs b/AdventOfCode/Startup.cs index aea08db..e1a011c 100644 --- a/AdventOfCode/Startup.cs +++ b/AdventOfCode/Startup.cs @@ -39,7 +39,7 @@ namespace AdventOfCode services.AddControllers(); services.AddSwaggerGen(c => { - c.SwaggerDoc("v1", new OpenApiInfo { Title = "AdventofCode", Version = "v1.0.0" }); + c.SwaggerDoc("v1", new OpenApiInfo { Title = "AdventofCode", Version = "v1.0.1" }); }); services.AddControllers(o => o.InputFormatters.Insert(o.InputFormatters.Count, new TextPlainInputFormatter())); services.AddSwaggerGenNewtonsoftSupport();