Add episodes controller

This commit is contained in:
2020-02-29 16:01:22 +01:00
parent 0cef2e3df2
commit 54c0fb2fd2
10 changed files with 190 additions and 23 deletions

View File

@@ -0,0 +1,21 @@
using System;
using System.Net;
using EstusShots.Shared.Models;
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Mvc.Filters;
namespace EstusShots.Server.Filters
{
[AttributeUsage(AttributeTargets.Class | AttributeTargets.Method)]
public class CustomExceptionFilterAttribute : ExceptionFilterAttribute
{
public override void OnException(ExceptionContext context)
{
var code = HttpStatusCode.InternalServerError;
context.HttpContext.Response.ContentType = "application/json";
context.HttpContext.Response.StatusCode = (int)code;
var response = new ApiResponse<CriticalErrorResponse>(new OperationResult(false, "Critical Server Error", context.Exception.Message));
context.Result = new JsonResult(response);
}
}
}