杨毅 7b909de91c Revert "pg1"
This reverts commit f564205e29cd2ef046fd58a85403d3959c7ecff4.
2024-10-02 03:02:23 +08:00

57 lines
1.3 KiB
C#
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

using Microsoft.AspNetCore.Mvc.Filters;
using Microsoft.AspNetCore.Mvc;
using Microsoft.Extensions.Caching.Memory;
using asg_form.Migrations;
using Mirai.Net.Sessions.Http.Managers;
public class MyExceptionFilter : IAsyncExceptionFilter
{
private readonly ILogger<MyExceptionFilter> logger;
private readonly IHostEnvironment env;
public MyExceptionFilter(ILogger<MyExceptionFilter> logger, IHostEnvironment env)
{
this.logger = logger;
this.env = env;
}
public Task OnExceptionAsync(ExceptionContext context)
{
Exception exception = context.Exception;
logger.LogError(exception, "UnhandledException occured");
ObjectResult result = new ObjectResult(new { code = 500, message = exception.Message });
try
{
MessageManager.SendGroupMessageAsync("860395385", $"<拉花实验室-错误>\r\n警告等级不严重\r\n内容{exception.Message}");
}
catch
{
}
result.StatusCode = 500;
context.Result = result;
context.ExceptionHandled = true;
return Task.CompletedTask;
}
}
public class code_st
{
public string message { get; set; }
public int status { get; set; }
}
public class error_mb
{
public int code { get; set; }
public string message { get; set; }
}