Example #1
0
 public static IExceptionMappingBuilder SerializeAsProblemDetails(this IExceptionMappingBuilder builder, IConfiguration configuration)
 {
     builder.Services
     .Configure <ProblemDetailsSerializationOptions>(configuration)
     .AddSingleton(ctx => ctx.GetService <IOptionsMonitor <ProblemDetailsSerializationOptions> >().CurrentValue)
     ;
     return(builder.AddExceptionHandler <ProblemDetailsSerializationHandler>());
 }
 /// <summary>
 /// Registers all <see cref="IExceptionHandler"/> found in the assembly <see cref="ForEvolve.ExceptionMapper"/>
 /// with singleton lifetime.
 /// </summary>
 public static IExceptionMappingBuilder MapHttpFallback(this IExceptionMappingBuilder builder, Action <FallbackExceptionHandlerOptions> setup = null)
 {
     if (setup != null)
     {
         builder.Services.Configure(setup);
     }
     return(builder.AddExceptionHandler <FallbackExceptionHandler>());
 }
Example #3
0
        public static IExceptionMappingBuilder Map <TException>(this IExceptionMappingBuilder builder, Action <FluentMapperBuilder <TException> > mapperAction)
            where TException : Exception
        {
            if (mapperAction == null)
            {
                throw new ArgumentNullException(nameof(mapperAction));
            }

            var handler      = new FluentExceptionHandler <TException>();
            var fluentMapper = new FluentMapperBuilder <TException>(builder, handler);

            builder.AddExceptionHandler(handler);
            mapperAction.Invoke(fluentMapper);
            return(builder);
        }
Example #4
0
 public static IExceptionMappingBuilder SerializeAsProblemDetails(this IExceptionMappingBuilder builder, ProblemDetailsSerializationOptions options)
 {
     builder.Services.AddSingleton(options);
     return(builder.AddExceptionHandler <ProblemDetailsSerializationHandler>());
 }