Show a nicer error if the config file doesn't exist

This commit is contained in:
Gervasio Marchand 2022-12-05 10:28:06 -03:00
parent ec328acb16
commit 509fbc964f
No known key found for this signature in database
GPG Key ID: B7736CB188DD0A38
2 changed files with 5 additions and 4 deletions

View File

@ -30,6 +30,11 @@ public class Config
return;
}
if (!File.Exists(path))
{
throw new Exception("Config file does not exist. Run the config command to create it.");
}
var data = JSON.Deserialize<ConfigData>(File.ReadAllText(path));
if (data.PublicKey == null || data.PrivateKey == null || data.Host == null)
{

View File

@ -1,10 +1,6 @@
using FakeRelay.Core;
using FakeRelay.Web.Services;
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.HttpOverrides;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Hosting;
var builder = WebApplication.CreateBuilder(args);
Config.Init(builder.Configuration.GetValue<string>("CONFIG_PATH"));