fix error handling

This commit is contained in:
Mikhail
2024-11-21 18:00:22 -05:00
parent 2e790e0861
commit 3be38c0d2a

View File

@@ -5,6 +5,7 @@ using EpinelPS.LobbyServer.Msgs.Stage;
using EpinelPS.StaticInfo; using EpinelPS.StaticInfo;
using EpinelPS.Utils; using EpinelPS.Utils;
using Google.Api; using Google.Api;
using Microsoft.AspNetCore.Server.Kestrel.Core;
using Microsoft.AspNetCore.Server.Kestrel.Https; using Microsoft.AspNetCore.Server.Kestrel.Https;
using Microsoft.Extensions.Logging.EventLog; using Microsoft.Extensions.Logging.EventLog;
using Microsoft.VisualBasic; using Microsoft.VisualBasic;
@@ -49,6 +50,7 @@ namespace EpinelPS
serverOptions.Listen(IPAddress.Any, 443, serverOptions.Listen(IPAddress.Any, 443,
listenOptions => listenOptions =>
{ {
listenOptions.Protocols = HttpProtocols.Http1AndHttp2AndHttp3;
listenOptions.UseHttps(AppDomain.CurrentDomain.BaseDirectory + @"site.pfx", ""); listenOptions.UseHttps(AppDomain.CurrentDomain.BaseDirectory + @"site.pfx", "");
}); });
@@ -766,15 +768,17 @@ namespace EpinelPS
response.AddRange([.. ResponseWithBytes]); response.AddRange([.. ResponseWithBytes]);
} }
} }
catch catch(Exception ex)
{ {
List<byte> ResponseWithBytes = List<byte> ResponseWithBytes =
[ .. Encoding.UTF8.GetBytes("HTTP/1.1 505 Internal Server Error\r\n"), [ .. Encoding.UTF8.GetBytes("HTTP/1.1 500 Internal Server Error\r\n"),
//.. Encoding.UTF8.GetBytes($"Content-Type: application/octet-stream+protobuf\r\n"), //.. Encoding.UTF8.GetBytes($"Content-Type: application/octet-stream+protobuf\r\n"),
.. Encoding.UTF8.GetBytes($"Content-Length: 0\r\n"), .. Encoding.UTF8.GetBytes($"Content-Length: 0\r\n"),
.. Encoding.UTF8.GetBytes($"\r\n"), .. Encoding.UTF8.GetBytes($"\r\n"),
]; ];
response.AddRange([.. ResponseWithBytes]); response.AddRange([.. ResponseWithBytes]);
Console.WriteLine("Exception during batch request: " + ex.ToString());
} }
// add boundary, also include http newline if there is binary content // add boundary, also include http newline if there is binary content