From cb43033336ab7df39155116b94caa7daab417f77 Mon Sep 17 00:00:00 2001 From: David Pine Date: Wed, 18 Jan 2023 20:09:08 -0600 Subject: [PATCH] Fix NRE warning. --- samples/HaveIBeenPwned.WebApi/Startup.cs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/samples/HaveIBeenPwned.WebApi/Startup.cs b/samples/HaveIBeenPwned.WebApi/Startup.cs index 2a0aacc..cfb7584 100644 --- a/samples/HaveIBeenPwned.WebApi/Startup.cs +++ b/samples/HaveIBeenPwned.WebApi/Startup.cs @@ -16,8 +16,9 @@ public void ConfigureServices(IServiceCollection services) { services.AddPwnedServices(options => { - options.ApiKey = _configuration["HibpOptions:ApiKey"]; - options.UserAgent = _configuration["HibpOptions:UserAgent"]; + options.ApiKey = _configuration["HibpOptions:ApiKey"] + ?? throw new Exception("Missing required HibpOptions:ApiKey configuration value."); + options.UserAgent = _configuration["HibpOptions:UserAgent"]!; }); services.AddControllers();