コード例 #1
0
 public WebApiControllerBase(
     ILogger <T> logger
     , Bugsnag.IClient bugSnag)
 {
     _logger  = logger;
     _bugSnag = bugSnag;
 }
コード例 #2
0
 public UsersRepository(
     ILogger <UsersRepository> logger
     , Bugsnag.IClient bugSnag
     , IConfiguration configuration) : base(logger, bugSnag)
 {
     _connectionString = configuration.GetConnectionString("Users");
 }
コード例 #3
0
 public WorkflowProductService(
     IJobRepository <Product, Guid> productRepository,
     IJobRepository <UserTask> taskRepository,
     IJobRepository <User> userRepository,
     IJobRepository <ProductWorkflow, Guid> productWorkflowRepository,
     IJobRepository <WorkflowDefinition> workflowDefinitionRepository,
     IJobRepository <ProductTransition> productTransitionRepository,
     IBackgroundJobClient backgroundJobClient,
     SendNotificationService sendNotificationService,
     IServiceProvider serviceProvider,
     Bugsnag.IClient bugsnagClient,
     WorkflowRuntime runtime
     )
 {
     ProductRepository            = productRepository;
     TaskRepository               = taskRepository;
     UserRepository               = userRepository;
     ProductWorkflowRepository    = productWorkflowRepository;
     WorkflowDefinitionRepository = workflowDefinitionRepository;
     ProductTransitionRepository  = productTransitionRepository;
     BackgroundJobClient          = backgroundJobClient;
     SendNotificationService      = sendNotificationService;
     ServiceProvider              = serviceProvider;
     BugsnagClient = bugsnagClient;
     Runtime       = runtime;
 }
コード例 #4
0
 public UsersController(
     ILogger <UsersController> logger
     , Bugsnag.IClient bugSnag
     , IUsersService usersService) : base(logger, bugSnag)
 {
     _usersService = usersService;
 }
コード例 #5
0
        public HomeController(Bugsnag.IClient bugsnag)
        {
            _bugsnag = bugsnag;
            _bugsnag.BeforeNotify(report =>
            {
                if (report.OriginalException is System.NotImplementedException)
                {
                    report.Event.Metadata.Add("paying account", true);
                    report.Event.Context = "an-important-context";
                }
            });

            // A BeforeNotify callback lets you evaluate, modify, add and remove data before sending the error to bugsnag. The actions here will be applied to *all* errors, handled and unhandled.
            _bugsnag.BeforeNotify(report =>
            {
                // In order to correlate errors with customer reports, or to see a list of users who experienced each error, you can attach user data in your callback
                report.Event.User = new Bugsnag.Payload.User
                {
                    Id    = "006",
                    Name  = "Hedy Lamarr",
                    Email = "*****@*****.**"
                };
                //this example makes some modifications that only apply to reports of error class "System.NotImplementedException".
                if (report.OriginalException is System.NotImplementedException)
                {
                    report.Event.Metadata.Add("account", new Dictionary <string, object> {
                        { "paying", true }
                    });
                    report.Event.Context = "an-important-context";
                }

                // note that using report.Ignore() will cancel the entire error report.
            });
        }
コード例 #6
0
 public UsersService(
     ILogger <UsersService> logger
     , Bugsnag.IClient bugSnag
     , IConfiguration configuration
     , IUsersRepository usersRepository) : base(logger, bugSnag)
 {
     _configuration   = configuration;
     _usersRepository = usersRepository;
     _usersTranslator = new UsersTranslator();
 }
コード例 #7
0
        public BaseLogger(
            ILogger logger
            , Bugsnag.IClient bugSnag
            , bool parametersAreRequired = true)
        {
            if (parametersAreRequired)
            {
                if (logger is null)
                {
                    throw new ArgumentNullException(nameof(logger));
                }

                if (bugSnag is null)
                {
                    throw new ArgumentNullException(nameof(bugSnag));
                }
            }

            _logger  = logger;
            _bugSnag = bugSnag;
        }
コード例 #8
0
 public ExceptionHandler(Bugsnag.IClient client)
 {
     _bugsnag = client;
 }
コード例 #9
0
        private async Task HandleExceptionAsync(HttpContext context, Exception exception, ILogger <ErrorHandlingMiddleware> logger, Bugsnag.IClient bugSnagClient)
        {
            var code = HttpStatusCode.InternalServerError;
            ResponseDTO <object> responseObj;

            // TODO figure out a way to propery solve exception handling and reporting for the 99% case...
            responseObj = new ResponseDTO <object>()
            {
                Data    = null,
                Errors  = Array.Empty <string>(),
                Message = exception.Message
            };

            if (exception is TarokBaseException tbe)
            {
                code = tbe.StatusCode;
                responseObj.Errors = tbe.AdditionalData;
            }

            logger.LogError(exception, exception.Message, code);

            bugSnagClient.Notify(exception);

            context.Response.ContentType = "application/json";
            context.Response.StatusCode  = (int)code;

            using (var writer = new StreamWriter(context.Response.Body))
            {
                _serializer.Serialize(writer, responseObj);
                await writer.FlushAsync();
            }
        }
コード例 #10
0
 public async Task Invoke(HttpContext context, ILogger <ErrorHandlingMiddleware> logger, Bugsnag.IClient bugSnagClient)
 {
     try
     {
         await _next(context);
     }
     catch (Exception ex)
     {
         await HandleExceptionAsync(context, ex, logger, bugSnagClient);
     }
 }