summary refs log tree commit diff
path: root/ReferenceClientProxyImplementation/Controllers/ErrorReportingProxy.cs
diff options
context:
space:
mode:
authorRory& <root@rory.gay>2026-02-23 02:03:20 +0100
committerRory& <root@rory.gay>2026-02-23 02:03:20 +0100
commit77a609758bb80bac9497d2e3988550f8be578407 (patch)
tree991a9d258ca4fece1132a1a344d0fe11e3b03d51 /ReferenceClientProxyImplementation/Controllers/ErrorReportingProxy.cs
downloadReferenceClientProxyImplementation-77a609758bb80bac9497d2e3988550f8be578407.tar.xz
Initial commit HEAD master
Diffstat (limited to 'ReferenceClientProxyImplementation/Controllers/ErrorReportingProxy.cs')
-rw-r--r--ReferenceClientProxyImplementation/Controllers/ErrorReportingProxy.cs34
1 files changed, 34 insertions, 0 deletions
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<ActionResult> 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<JsonObject>(lines[0]), + ["typeInfo"] = JsonSerializer.Deserialize<JsonObject>(lines[1]), + ["stackTrace"] = JsonSerializer.Deserialize<JsonObject>(lines[2]), + }; + + if (lines.Length > 3) + for (var i = 3; i < lines.Length; i++) { + data[$"unk_line_{i}"] = JsonSerializer.Deserialize<JsonValue>(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