private static ProblemDetails ResolveProblemDetails(ProblemDetailsFactory problemDetailsFactory, IExceptionHandlerFeature contextFeature)
        {
            var problemDetails = default(ProblemDetails);

            if (contextFeature.Error is BadHttpRequestException badHttpRequestException)
            {
                problemDetails = problemDetailsFactory.GetValidationProblem(badHttpRequestException.Message);
            }
            else
            {
                problemDetails = problemDetailsFactory.GetInternalServerError(contextFeature.Error);
            }
            return(problemDetails);
        }