improve error output when configuration is invalid

This commit is contained in:
RaidMax 2022-02-15 20:16:21 -06:00
parent 9a6d7c6a20
commit ea18a286b2
3 changed files with 5 additions and 7 deletions

View File

@ -412,7 +412,7 @@ namespace IW4MAdmin.Application
if (!validationResult.IsValid)
{
throw new ConfigurationException(_translationLookup["MANAGER_CONFIGURATION_ERROR"])
throw new ConfigurationException("Could not validate configuration")
{
Errors = validationResult.Errors.Select(_error => _error.ErrorMessage).ToArray(),
ConfigurationFileName = ConfigHandler.FileName

View File

@ -18,6 +18,7 @@ using SharedLibraryCore.Repositories;
using SharedLibraryCore.Services;
using Stats.Dtos;
using System;
using System.IO;
using System.Linq;
using System.Net.Http;
using System.Text;
@ -138,11 +139,8 @@ namespace IW4MAdmin.Application
if (e is ConfigurationException configException)
{
if (translationLookup != null)
{
Console.WriteLine(translationLookup[configException.Message]
.FormatExt(configException.ConfigurationFileName));
}
Console.WriteLine("{{fileName}} contains an error."
.FormatExt(Path.GetFileName(configException.ConfigurationFileName)));
foreach (var error in configException.Errors)
{

View File

@ -59,7 +59,7 @@ namespace IW4MAdmin.Application.Misc
catch (Exception e)
{
throw new ConfigurationException("MANAGER_CONFIGURATION_ERROR")
throw new ConfigurationException("Could not load configuration")
{
Errors = new[] { e.Message },
ConfigurationFileName = FileName