diff --git a/src/Serval/src/Serval.ApiServer/Controllers/StatusController.cs b/src/Serval/src/Serval.ApiServer/Controllers/StatusController.cs index 3b3a9321..d31c81fe 100644 --- a/src/Serval/src/Serval.ApiServer/Controllers/StatusController.cs +++ b/src/Serval/src/Serval.ApiServer/Controllers/StatusController.cs @@ -6,10 +6,11 @@ namespace Serval.ApiServer.Controllers; public class StatusController( HealthCheckService healthCheckService, IAuthorizationService authService, + Bugsnag.IClient bugsnagClient, IWebHostEnvironment env, IConfiguration configuration, ILogger logger -) : ServalControllerBase(authService) +) : ServalControllerBase(authService, bugsnagClient) { private readonly HealthCheckService _healthCheckService = healthCheckService; private readonly IWebHostEnvironment _env = env; diff --git a/src/Serval/src/Serval.Assessment/Controllers/AssessmentEnginesController.cs b/src/Serval/src/Serval.Assessment/Controllers/AssessmentEnginesController.cs index 459d3b34..a70c587a 100644 --- a/src/Serval/src/Serval.Assessment/Controllers/AssessmentEnginesController.cs +++ b/src/Serval/src/Serval.Assessment/Controllers/AssessmentEnginesController.cs @@ -6,12 +6,13 @@ [FeatureGate("Assessment")] public class AssessmentEnginesController( IAuthorizationService authService, + Bugsnag.IClient bugsnagClient, IEngineService engineService, IJobService jobService, IResultService resultService, IOptionsMonitor apiOptions, IUrlService urlService -) : ServalControllerBase(authService) +) : ServalControllerBase(authService, bugsnagClient) { private static readonly JsonSerializerOptions ObjectJsonSerializerOptions = new() { Converters = { new ObjectToInferredTypesConverter() } }; diff --git a/src/Serval/src/Serval.DataFiles/Controllers/DataFilesController.cs b/src/Serval/src/Serval.DataFiles/Controllers/DataFilesController.cs index 32218a68..9af685fb 100644 --- a/src/Serval/src/Serval.DataFiles/Controllers/DataFilesController.cs +++ b/src/Serval/src/Serval.DataFiles/Controllers/DataFilesController.cs @@ -5,9 +5,10 @@ [OpenApiTag("Files")] public class DataFilesController( IAuthorizationService authService, + Bugsnag.IClient bugsnagClient, IDataFileService dataFileService, IUrlService urlService -) : ServalControllerBase(authService) +) : ServalControllerBase(authService, bugsnagClient) { private readonly IDataFileService _dataFileService = dataFileService; private readonly IUrlService _urlService = urlService; diff --git a/src/Serval/src/Serval.Shared/Controllers/BugsnagExceptionFilter.cs b/src/Serval/src/Serval.Shared/Controllers/BugsnagExceptionFilter.cs index 614ce4c1..3f744428 100644 --- a/src/Serval/src/Serval.Shared/Controllers/BugsnagExceptionFilter.cs +++ b/src/Serval/src/Serval.Shared/Controllers/BugsnagExceptionFilter.cs @@ -6,6 +6,6 @@ public class BugsnagExceptionFilter : ExceptionFilterAttribute { public override void OnException(ExceptionContext context) { - context.HttpContext.RequestServices.GetService()?.Notify(context.Exception); + context.HttpContext.RequestServices.GetService()?.Notify(context.Exception); } } diff --git a/src/Serval/src/Serval.Shared/Controllers/ServalControllerBase.cs b/src/Serval/src/Serval.Shared/Controllers/ServalControllerBase.cs index 47ad5290..5f0c3494 100644 --- a/src/Serval/src/Serval.Shared/Controllers/ServalControllerBase.cs +++ b/src/Serval/src/Serval.Shared/Controllers/ServalControllerBase.cs @@ -2,6 +2,7 @@ [ApiController] [Produces("application/json")] +[TypeFilter(typeof(BugsnagExceptionFilter))] [TypeFilter(typeof(OperationCancelledExceptionFilter))] [TypeFilter(typeof(NotSupportedExceptionFilter))] [TypeFilter(typeof(ServiceUnavailableExceptionFilter))] @@ -10,10 +11,11 @@ [TypeFilter(typeof(NotFoundExceptionFilter))] [TypeFilter(typeof(ForbiddenExceptionFilter))] [TypeFilter(typeof(BadRequestExceptionFilter))] -public abstract class ServalControllerBase(IAuthorizationService authService, IClient bugsnagClient) : Controller +public abstract class ServalControllerBase(IAuthorizationService authService, Bugsnag.IClient bugsnagClient) + : Controller { private readonly IAuthorizationService _authService = authService; - protected readonly IClient BugsnagClient = bugsnagClient; + protected readonly Bugsnag.IClient BugsnagClient = bugsnagClient; protected string Owner => User.Identity!.Name!; diff --git a/src/Serval/src/Serval.Shared/Usings.cs b/src/Serval/src/Serval.Shared/Usings.cs index ce15c864..3e84144f 100644 --- a/src/Serval/src/Serval.Shared/Usings.cs +++ b/src/Serval/src/Serval.Shared/Usings.cs @@ -1,7 +1,6 @@ global using System.Diagnostics; global using System.Text.Json; global using System.Text.Json.Serialization; -global using Bugsnag; global using Grpc.Core; global using Grpc.Net.ClientFactory; global using Microsoft.AspNetCore.Authorization; diff --git a/src/Serval/src/Serval.Translation/Controllers/TranslationEngineTypesController.cs b/src/Serval/src/Serval.Translation/Controllers/TranslationEngineTypesController.cs index 4e5458d1..82a789a1 100644 --- a/src/Serval/src/Serval.Translation/Controllers/TranslationEngineTypesController.cs +++ b/src/Serval/src/Serval.Translation/Controllers/TranslationEngineTypesController.cs @@ -3,8 +3,11 @@ [ApiVersion(1.0)] [Route("api/v{version:apiVersion}/translation/engine-types")] [OpenApiTag("Translation Engines")] -public class TranslationEngineTypesController(IAuthorizationService authService, IEngineService engineService) - : ServalControllerBase(authService) +public class TranslationEngineTypesController( + IAuthorizationService authService, + Bugsnag.IClient bugsnagClient, + IEngineService engineService +) : ServalControllerBase(authService, bugsnagClient) { private readonly IEngineService _engineService = engineService; diff --git a/src/Serval/src/Serval.Translation/Controllers/TranslationEnginesController.cs b/src/Serval/src/Serval.Translation/Controllers/TranslationEnginesController.cs index 052d7ede..595cb826 100644 --- a/src/Serval/src/Serval.Translation/Controllers/TranslationEnginesController.cs +++ b/src/Serval/src/Serval.Translation/Controllers/TranslationEnginesController.cs @@ -5,13 +5,14 @@ [OpenApiTag("Translation Engines")] public class TranslationEnginesController( IAuthorizationService authService, + Bugsnag.IClient bugsnagClient, IEngineService engineService, IBuildService buildService, IPretranslationService pretranslationService, IOptionsMonitor apiOptions, IUrlService urlService, ILogger logger -) : ServalControllerBase(authService) +) : ServalControllerBase(authService, bugsnagClient) { private static readonly JsonSerializerOptions ObjectJsonSerializerOptions = new() { Converters = { new ObjectToInferredTypesConverter() } }; diff --git a/src/Serval/src/Serval.Webhooks/Controllers/WebhooksController.cs b/src/Serval/src/Serval.Webhooks/Controllers/WebhooksController.cs index 8758faca..a2bdbf3d 100644 --- a/src/Serval/src/Serval.Webhooks/Controllers/WebhooksController.cs +++ b/src/Serval/src/Serval.Webhooks/Controllers/WebhooksController.cs @@ -2,8 +2,12 @@ [ApiVersion(1.0)] [Route("api/v{version:apiVersion}/hooks")] -public class WebhooksController(IAuthorizationService authService, IWebhookService hookService, IUrlService urlService) - : ServalControllerBase(authService) +public class WebhooksController( + IAuthorizationService authService, + Bugsnag.IClient bugsnagClient, + IWebhookService hookService, + IUrlService urlService +) : ServalControllerBase(authService, bugsnagClient) { private readonly IWebhookService _hookService = hookService; private readonly IUrlService _urlService = urlService;