Added sentry support
This commit is contained in:
23
PdfService/ExceptionHandlerMiddleware.cs
Normal file
23
PdfService/ExceptionHandlerMiddleware.cs
Normal file
@@ -0,0 +1,23 @@
|
||||
namespace PdfService;
|
||||
|
||||
public class ExceptionHandlerMiddleware
|
||||
{
|
||||
private readonly RequestDelegate _next;
|
||||
|
||||
public ExceptionHandlerMiddleware(RequestDelegate next)
|
||||
{
|
||||
_next = next;
|
||||
}
|
||||
|
||||
public async Task InvokeAsync(HttpContext context)
|
||||
{
|
||||
try
|
||||
{
|
||||
await _next(context);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
SentrySdk.CaptureException(ex);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -9,6 +9,7 @@
|
||||
<ItemGroup>
|
||||
<PackageReference Include="dotenv.net" Version="4.0.0" />
|
||||
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
|
||||
<PackageReference Include="Sentry" Version="6.0.0" />
|
||||
<PackageReference Include="Stimulsoft.Reports.Engine.NetCore" Version="2025.2.3" />
|
||||
</ItemGroup>
|
||||
|
||||
|
||||
@@ -14,6 +14,8 @@ SentrySdk.Init(options =>
|
||||
var builder = WebApplication.CreateBuilder(args);
|
||||
var app = builder.Build();
|
||||
|
||||
app.UseMiddleware<ExceptionHandlerMiddleware>();
|
||||
|
||||
app.MapPost("/Print", async (HttpContext context) =>
|
||||
{
|
||||
var request = context.Request;
|
||||
|
||||
Reference in New Issue
Block a user