using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Mvc.Filters;

namespace Api
{
  public class CustomExceptionFilter : IExceptionFilter
  {
    public void OnException(ExceptionContext context)
    {
      switch (context.Exception)
      {
        case System.InvalidOperationException:
          context.Result = new NotFoundResult();
          break;
        case UserNotConnected:
          context.Result = new UnauthorizedResult();
          break;
      }
    }
  }
}