<commit_before>﻿namespace Miruken.Http
{
    using System;
    using System.Linq;
    using System.Security;
    using System.Security.Authentication;
    using Api;
    using Callback;
    using Map;
    using Validate;
    using FluentValidationException = FluentValidation.ValidationException;

#if NETSTANDARD
    using Microsoft.AspNetCore.Http;
#else
    using System.Data;
    using System.Net;
#endif

    public class ErrorMapping : Handler
    {
        [Maps]
        public int MapStatusCode(ArgumentException exception)
        {
#if NETSTANDARD
            return StatusCodes.Status400BadRequest;
#else
            return (int)HttpStatusCode.BadRequest;
#endif
        }

        [Maps]
        public int MapStatusCode(NotImplementedException exception)
        {
#if NETSTANDARD
            return StatusCodes.Status405MethodNotAllowed;
#else
            return (int)HttpStatusCode.MethodNotAllowed;
#endif
        }

        [Maps]
        public int MapStatusCode(SecurityException exception)
        {
#if NETSTANDARD
            return StatusCodes.Status401Unauthorized;
#else
            return (int)HttpStatusCode.Unauthorized;
#endif
        }

        [Maps]
        public int MapStatusCode(AuthenticationException exception)
        {
#if NETSTANDARD
            return StatusCodes.Status401Unauthorized;
#else
            return (int)HttpStatusCode.Unauthorized;
#endif
        }

        [Maps]
        public int MapStatusCode(UnauthorizedAccessException exception)
        {
#if NETSTANDARD
            return StatusCodes.Status403Forbidden;
#else
            return (int)HttpStatusCode.Forbidden;
#endif
        }

        [Maps]
        public int MapStatusCode(NotSupportedException exception)
        {
#if NETSTANDARD
            return StatusCodes.Status501NotImplemented;
#else
            return (int)HttpStatusCode.NotImplemented;
#endif
        }

#if NETFULL
        [Maps]
        public int MapStatusCode(OptimisticConcurrencyException exception)
        {
            return (int)HttpStatusCode.Conflict;
        }
#endif

        [Maps]
        public int MapStatusCode(NotFoundException exception)
        {
#if NETSTANDARD
            return StatusCodes.Status404NotFound;
#else
            return (int)HttpStatusCode.NotFound;
#endif
        }

        [Maps]
        public int MapStatusCode(ValidationException exception)
        {
#if NETSTANDARD
            return StatusCodes.Status422UnprocessableEntity;
#else
            return HttpStatusCodeEx.UnprocessableEntityCode;
#endif
        }

        [Maps]
        public int MapStatusCode(FluentValidationException exception)
        {
#if NETSTANDARD
            return StatusCodes.Status422UnprocessableEntity;
#else
            return HttpStatusCodeEx.UnprocessableEntityCode;
#endif
        }

        [Maps, Format(typeof(Exception))]
        public string MapNotFoundException( NotFoundException exception)
        {
            return exception.ToString();
        }

        [Maps, Format(typeof(Exception))]
        public MultipleErrors MapAggregateException(
            AggregateException exception, IHandler composer)
        {
            return new MultipleErrors
            {
                Errors = exception.InnerExceptions
                    .Select(ex => composer.Map<object>(ex, typeof(Exception)))
                    .ToArray()
            };
        }<commit_msg>Map NotFoundException to exception message<commit_after>﻿namespace Miruken.Http
{
    using System;
    using System.Linq;
    using System.Security;
    using System.Security.Authentication;
    using Api;
    using Callback;
    using Map;
    using Validate;
    using FluentValidationException = FluentValidation.ValidationException;

#if NETSTANDARD
    using Microsoft.AspNetCore.Http;
#else
    using System.Data;
    using System.Net;
#endif

    public class ErrorMapping : Handler
    {
        [Maps]
        public int MapStatusCode(ArgumentException exception)
        {
#if NETSTANDARD
            return StatusCodes.Status400BadRequest;
#else
            return (int)HttpStatusCode.BadRequest;
#endif
        }

        [Maps]
        public int MapStatusCode(NotImplementedException exception)
        {
#if NETSTANDARD
            return StatusCodes.Status405MethodNotAllowed;
#else
            return (int)HttpStatusCode.MethodNotAllowed;
#endif
        }

        [Maps]
        public int MapStatusCode(SecurityException exception)
        {
#if NETSTANDARD
            return StatusCodes.Status401Unauthorized;
#else
            return (int)HttpStatusCode.Unauthorized;
#endif
        }

        [Maps]
        public int MapStatusCode(AuthenticationException exception)
        {
#if NETSTANDARD
            return StatusCodes.Status401Unauthorized;
#else
            return (int)HttpStatusCode.Unauthorized;
#endif
        }

        [Maps]
        public int MapStatusCode(UnauthorizedAccessException exception)
        {
#if NETSTANDARD
            return StatusCodes.Status403Forbidden;
#else
            return (int)HttpStatusCode.Forbidden;
#endif
        }

        [Maps]
        public int MapStatusCode(NotSupportedException exception)
        {
#if NETSTANDARD
            return StatusCodes.Status501NotImplemented;
#else
            return (int)HttpStatusCode.NotImplemented;
#endif
        }

#if NETFULL
        [Maps]
        public int MapStatusCode(OptimisticConcurrencyException exception)
        {
            return (int)HttpStatusCode.Conflict;
        }
#endif

        [Maps]
        public int MapStatusCode(NotFoundException exception)
        {
#if NETSTANDARD
            return StatusCodes.Status404NotFound;
#else
            return (int)HttpStatusCode.NotFound;
#endif
        }

        [Maps]
        public int MapStatusCode(ValidationException exception)
        {
#if NETSTANDARD
            return StatusCodes.Status422UnprocessableEntity;
#else
            return HttpStatusCodeEx.UnprocessableEntityCode;
#endif
        }

        [Maps]
        public int MapStatusCode(FluentValidationException exception)
        {
#if NETSTANDARD
            return StatusCodes.Status422UnprocessableEntity;
#else
            return HttpStatusCodeEx.UnprocessableEntityCode;
#endif
        }

        [Maps, Format(typeof(Exception))]
        public string MapNotFoundException(NotFoundException exception)
        {
            return exception.Message;
        }

        [Maps, Format(typeof(Exception))]
        public MultipleErrors MapAggregateException(
            AggregateException exception, IHandler composer)
        {
            return new MultipleErrors
            {
                Errors = exception.InnerExceptions
                    .Select(ex => composer.Map<object>(ex, typeof(Exception)))
                    .ToArray()
            };
        }
{'fraction_non_alphanumeric': 0.06548230803112612, 'fraction_numerical': 0.007928351196593745, 'mean_word_length': 2.234567901234568, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5376984', 'n_tokens_mistral': 1776, 'n_tokens_neox': 1756, 'n_words': 381}