From 77a609758bb80bac9497d2e3988550f8be578407 Mon Sep 17 00:00:00 2001 From: Rory& Date: Mon, 23 Feb 2026 02:03:20 +0100 Subject: Initial commit --- .../Controllers/ErrorReportingProxy.cs | 34 ++++++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100644 ReferenceClientProxyImplementation/Controllers/ErrorReportingProxy.cs (limited to 'ReferenceClientProxyImplementation/Controllers/ErrorReportingProxy.cs') diff --git a/ReferenceClientProxyImplementation/Controllers/ErrorReportingProxy.cs b/ReferenceClientProxyImplementation/Controllers/ErrorReportingProxy.cs new file mode 100644 index 0000000..acc186b --- /dev/null +++ b/ReferenceClientProxyImplementation/Controllers/ErrorReportingProxy.cs @@ -0,0 +1,34 @@ +using System.Text.Json; +using System.Text.Json.Nodes; +using Microsoft.AspNetCore.Mvc; + +namespace ReferenceClientProxyImplementation.Controllers; + +[Controller] +[Route("/")] +public class ErrorReportingProxy : Controller { + [HttpPost("/error-reporting-proxy/web")] + public async Task HandleErrorReport() { + // read body as string + var body = await new StreamReader(Request.Body).ReadToEndAsync(); + var lines = body.Split('\n'); + var data = new JsonObject() { + ["eventInfo"] = JsonSerializer.Deserialize(lines[0]), + ["typeInfo"] = JsonSerializer.Deserialize(lines[1]), + ["stackTrace"] = JsonSerializer.Deserialize(lines[2]), + }; + + if (lines.Length > 3) + for (var i = 3; i < lines.Length; i++) { + data[$"unk_line_{i}"] = JsonSerializer.Deserialize(lines[i]); + } + + if (!System.IO.Directory.Exists("error_reports")) + System.IO.Directory.CreateDirectory("error_reports"); + await System.IO.File.WriteAllTextAsync($"error_reports/web_{DateTimeOffset.UtcNow.ToUnixTimeMilliseconds()}.json", data.ToJsonString(new JsonSerializerOptions { + WriteIndented = true + })); + + return NoContent(); + } +} \ No newline at end of file -- cgit 1.5.1