| | | 1 | | using ZhEaIsNsAaBn.Utilities.APIExceptionHandlers; |
| | | 2 | | |
| | | 3 | | // ReSharper disable once CheckNamespace |
| | | 4 | | namespace Microsoft.Extensions.DependencyInjection; |
| | | 5 | | |
| | | 6 | | /// <summary>Registers the API exception handlers.</summary> |
| | | 7 | | public static class APIExceptionHandlersRegistration |
| | | 8 | | { |
| | | 9 | | /// <summary> |
| | | 10 | | /// Starts a fluent registration of the exception handlers; <b>call <see cref="IExceptionHandlersBuilder.Build"/> at |
| | | 11 | | /// nothing is registered before it. <c>Build()</c> adds, in order, the JSON, validation, business, external-service |
| | | 12 | | /// handlers recorded with <c>With*</c>, and the fallback last, plus problem details written as the <see cref="BaseR |
| | | 13 | | /// (status-code pages included). Call <c>app.UseExceptionHandler()</c> in the pipeline. Statuses come from |
| | | 14 | | /// <see cref="APIResponsesSettings"/>: configure them once with <c>services.AddAPIResponses( s => … )</c> (befor |
| | | 15 | | /// returned errors and exceptions map the same way. |
| | | 16 | | /// </summary> |
| | | 17 | | /// <param name="services">The service collection.</param> |
| | | 18 | | /// <returns>The builder.</returns> |
| | | 19 | | /// <exception cref="ArgumentNullException"><paramref name="services"/> is <see langword="null"/>.</exception> |
| | | 20 | | /// <example><code>services.AddCustomExceptionHandlers().WithDatabaseHandler().WithHandler<MyHandler>().Build( |
| | 116 | 21 | | public static IExceptionHandlersBuilder AddCustomExceptionHandlers( this IServiceCollection services ) => new Except |
| | | 22 | | } |