First Commit
This commit is contained in:
@@ -0,0 +1,44 @@
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
|
||||
namespace JobTrackerApi.Controllers
|
||||
{
|
||||
[ApiController]
|
||||
[Route("api/client-errors")]
|
||||
public class ClientErrorsController : ControllerBase
|
||||
{
|
||||
private readonly ILogger<ClientErrorsController> _logger;
|
||||
|
||||
public ClientErrorsController(ILogger<ClientErrorsController> logger)
|
||||
{
|
||||
_logger = logger;
|
||||
}
|
||||
|
||||
public sealed record ClientErrorReport(
|
||||
string? ErrorId,
|
||||
string? Message,
|
||||
string? Stack,
|
||||
string? ComponentStack,
|
||||
string? Url,
|
||||
string? UserAgent,
|
||||
string? At
|
||||
);
|
||||
|
||||
[HttpPost]
|
||||
public IActionResult Report([FromBody] ClientErrorReport report)
|
||||
{
|
||||
_logger.LogError(
|
||||
"ClientError {ErrorId} at {At} url={Url} ua={UserAgent} msg={Message}\n{Stack}\n{ComponentStack}",
|
||||
report.ErrorId ?? "unknown",
|
||||
report.At ?? "unknown",
|
||||
report.Url ?? "unknown",
|
||||
report.UserAgent ?? "unknown",
|
||||
report.Message ?? "unknown",
|
||||
report.Stack ?? "",
|
||||
report.ComponentStack ?? ""
|
||||
);
|
||||
|
||||
return NoContent();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user