<commit_before>using Hellang.Middleware.ProblemDetails;
using Microsoft.AspNetCore.Mvc;

var builder = WebApplication.CreateBuilder(args);

builder.Services.AddEndpointsApiExplorer();
builder.Services.AddSwaggerGen();

// ProblemDetails requires the registration of IActionResultExecutor<ObjectResult>
// this is done by invoking either AddMvcCore() or AddControllers()
builder.Services.AddControllers();

// Configure problem details
builder.Services.AddProblemDetails(options =>
{
    // Only include exception details in a development environment. There's really no need
    // to set this as it's the default behavior. It's just included here for completeness :)
    options.IncludeExceptionDetails = (ctx, ex) => builder.Environment.IsDevelopment();

    // This will map UserNotFoundException to the 404 Not Found status code and return custom problem details.
    options.Map<UserNotFoundException>(ex => new ProblemDetails
    {
        Title = "Could not find user",
        Status = StatusCodes.Status404NotFound,
        Detail = ex.Message,
    });

    // This will map NotImplementedException to the 501 Not Implemented status code.
    options.MapToStatusCode<NotImplementedException>(StatusCodes.Status501NotImplemented);

    // You can configure the middleware to re-throw certain types of exceptions, all exceptions or based on a predicate.
    // This is useful if you have upstream middleware that  needs to do additional handling of exceptions.
    options.Rethrow<NotSupportedException>();<commit_msg>Remove redundant call from sample<commit_after>using Hellang.Middleware.ProblemDetails;
using Microsoft.AspNetCore.Mvc;

var builder = WebApplication.CreateBuilder(args);

builder.Services.AddEndpointsApiExplorer();
builder.Services.AddSwaggerGen();

// Configure problem details
builder.Services.AddProblemDetails(options =>
{
    // Only include exception details in a development environment. There's really no need
    // to set this as it's the default behavior. It's just included here for completeness :)
    options.IncludeExceptionDetails = (ctx, ex) => builder.Environment.IsDevelopment();

    // This will map UserNotFoundException to the 404 Not Found status code and return custom problem details.
    options.Map<UserNotFoundException>(ex => new ProblemDetails
    {
        Title = "Could not find user",
        Status = StatusCodes.Status404NotFound,
        Detail = ex.Message,
    });

    // This will map NotImplementedException to the 501 Not Implemented status code.
    options.MapToStatusCode<NotImplementedException>(StatusCodes.Status501NotImplemented);

    // You can configure the middleware to re-throw certain types of exceptions, all exceptions or based on a predicate.
    // This is useful if you have upstream middleware that  needs to do additional handling of exceptions.
    options.Rethrow<NotSupportedException>();
{'fraction_non_alphanumeric': 0.07601527247483512, 'fraction_numerical': 0.008330440819160014, 'mean_word_length': 4.317343173431734, 'pattern_counts': {'":': 0, '<': 10, '<?xml version=': 0, '>': 16, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3132685', 'n_tokens_mistral': 729, 'n_tokens_neox': 690, 'n_words': 255}