You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

ExceptionLoggerAttribute.cs 643B

123456789101112131415161718
  1. using System;
  2. using System.Net.Http;
  3. using System.Web.Http.Filters;
  4. using iiie.Logs.DataAccess;
  5. using iiie.Logs.DBO;
  6. namespace iiie.WebApiUtils.BusinessManager
  7. {
  8. [AttributeUsage(AttributeTargets.Method)]
  9. public class ExceptionLoggerAttribute : ExceptionFilterAttribute
  10. {
  11. public override void OnException(HttpActionExecutedContext context)
  12. {
  13. var result = Logger.Error<int>(ResultStatus.InternalError, context.Exception);
  14. context.Response = context.Request.CreateErrorResponse(BMRHandler<int>.ResultStatusToHttp(result.Status), BMRHandler<int>.OpResultToString(result));
  15. }
  16. }
  17. }